schema parsers BUGFIX setting correct return error code
diff --git a/src/parser_yang.c b/src/parser_yang.c
index 22cfce2..71155a1 100644
--- a/src/parser_yang.c
+++ b/src/parser_yang.c
@@ -4474,7 +4474,7 @@
     }
 
     mod_p = calloc(1, sizeof *mod_p);
-    LY_CHECK_ERR_GOTO(!mod_p, LOGMEM((*context)->ctx), cleanup);
+    LY_CHECK_ERR_GOTO(!mod_p, LOGMEM((*context)->ctx); ret = LY_EMEM, cleanup);
     mod_p->parsing = 1;
 
     /* substatements */
diff --git a/src/parser_yin.c b/src/parser_yin.c
index bfaa155..2d75c64 100644
--- a/src/parser_yin.c
+++ b/src/parser_yin.c
@@ -3539,7 +3539,7 @@
     }
 
     mod_p = calloc(1, sizeof *mod_p);
-    LY_CHECK_ERR_GOTO(!mod_p, LOGMEM(ctx), cleanup);
+    LY_CHECK_ERR_GOTO(!mod_p, LOGMEM(ctx); ret = LY_EMEM, cleanup);
     mod_p->parsing = 1;
 
     ret = yin_parse_submod(*yin_ctx, mod_p);
diff --git a/src/tree_schema.c b/src/tree_schema.c
index 3b6bc19..adc84fc 100644
--- a/src/tree_schema.c
+++ b/src/tree_schema.c
@@ -914,6 +914,7 @@
         break;
     }
     LY_CHECK_GOTO(ret, error);
+    assert(submod);
 
     /* make sure that the newest revision is at position 0 */
     lysp_sort_revisions(submod->revs);