xml BUGFIX memory leaks
diff --git a/src/xml.c b/src/xml.c
index 8ae6221..dea01a8 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -327,7 +327,7 @@
             } else if (rc) {
                 /* some parsing error, so pass it */
                 (*input) = in;
-                return rc;
+                goto error;
             } else {
                 /* whitespace-only content */
                 len = offset;
@@ -461,10 +461,10 @@
                     LOGVAL(ctx, LY_VLOG_LINE, &context->line, LYVE_SYNTAX, "Mixed XML content is not allowed (%.*s).",
                            offset + (in - (*input)), &(*input)[-offset]);
                     free(e);
-                    return LY_EVALID;
+                    goto error;
                 } else if (rc) {
-                    /* some parsing error, so pass it */
-                    return rc;
+                    /* some parsing error */
+                    goto error;
                 } else {
                     /* closing element, so we have regular content */
                     context->status++;