yang parser BUGFIX allocating NULL-terminated arrays
diff --git a/src/parser_yang.c b/src/parser_yang.c
index f904680..5cf8276 100644
--- a/src/parser_yang.c
+++ b/src/parser_yang.c
@@ -1474,7 +1474,7 @@
 
     /* allocate new pointer */
     for (count = 1; (*texts) && (*texts)[count - 1]; ++count);
-    *texts = realloc(*texts, count * sizeof **texts);
+    *texts = realloc(*texts, (1 + count) * sizeof **texts);
     LY_CHECK_ERR_RET(!*texts, LOGMEM(ctx->ctx), LY_EMEM);
 
     /* get value */
@@ -1482,6 +1482,7 @@
     LY_CHECK_RET(ret);
 
     INSERT_WORD(ctx, buf, (*texts)[count - 1], word, word_len);
+    (*texts)[count] = NULL; /* NULL-termination of the array */
     YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret) {
         LY_CHECK_RET(ret);
 
@@ -4392,7 +4393,6 @@
         }
         LY_CHECK_RET(ret);
     }
-    LY_CHECK_RET(ret);
 
     return ret;
 }