json & schema_compile BUGFIX uninitialized variables

Fixes #1787
diff --git a/src/json.c b/src/json.c
index cbe38e9..59ae61c 100644
--- a/src/json.c
+++ b/src/json.c
@@ -963,7 +963,7 @@
 
     if (toplevel) {
         /* we are done */
-        return LY_SUCCESS;
+        goto result;
     }
 
     /* continue with the next token */
diff --git a/src/schema_compile.c b/src/schema_compile.c
index aeeb239..760c052 100644
--- a/src/schema_compile.c
+++ b/src/schema_compile.c
@@ -151,6 +151,13 @@
 {
     LY_ARRAY_COUNT_TYPE u;
 
+    if (instance_p) {
+        *instance_p = NULL;
+    }
+    if (cardinality_p) {
+        *cardinality_p = 0;
+    }
+
     LY_ARRAY_FOR(ext->substmts, u) {
         if (LY_STMT_IS_DATA_NODE(substmt)) {
             if (!LY_STMT_IS_DATA_NODE(ext->substmts[u].stmt)) {
diff --git a/src/schema_compile_node.c b/src/schema_compile_node.c
index 3f61230..e1da522 100644
--- a/src/schema_compile_node.c
+++ b/src/schema_compile_node.c
@@ -2408,7 +2408,8 @@
         struct lysc_node **list;
 
         if (ctx->ext) {
-            lysc_ext_substmt(ctx->ext, LY_STMT_CONTAINER /* matches all data nodes */, (void **)&list, NULL);
+            /* container matches all data nodes */
+            lysc_ext_substmt(ctx->ext, LY_STMT_CONTAINER, (void **)&list, NULL);
         } else if (node->nodetype == LYS_RPC) {
             list = (struct lysc_node **)&ctx->cur_mod->compiled->rpcs;
         } else if (node->nodetype == LYS_NOTIF) {