parser json BUGFIX proper cleanup

Refs #2077
diff --git a/src/parser_json.c b/src/parser_json.c
index 5143fae..fca58f4 100644
--- a/src/parser_json.c
+++ b/src/parser_json.c
@@ -2010,7 +2010,7 @@
         struct lyd_node **envp, struct ly_set *parsed, struct lyd_ctx **lydctx_p)
 {
     LY_ERR rc = LY_SUCCESS, r;
-    struct lyd_json_ctx *lydctx;
+    struct lyd_json_ctx *lydctx = NULL;
     enum LYJSON_PARSER_STATUS status;
     uint32_t i, int_opts = 0, close_elem = 0;
 
@@ -2108,7 +2108,7 @@
 
 cleanup:
     /* there should be no unres stored if validation should be skipped */
-    assert(!(parse_opts & LYD_PARSE_ONLY) || (!lydctx->node_types.count && !lydctx->meta_types.count &&
+    assert(!(parse_opts & LYD_PARSE_ONLY) || !lydctx || (!lydctx->node_types.count && !lydctx->meta_types.count &&
             !lydctx->node_when.count));
 
     if (rc) {