yin parser BUGFIX insert empty strings into dictionary correctly
diff --git a/src/parser_yin.c b/src/parser_yin.c
index 167ea5a..8bab996 100644
--- a/src/parser_yin.c
+++ b/src/parser_yin.c
@@ -273,8 +273,12 @@
/* string is no longer supposed to be freed when the sized array is freed */
iter->dynamic_content = 0;
} else {
- *arg_val = lydict_insert(ctx->xml_ctx.ctx, iter->content, iter->content_len);
- LY_CHECK_RET(!(*arg_val), LY_EMEM);
+ if (iter->content_len == 0) {
+ *arg_val = lydict_insert(ctx->xml_ctx.ctx, "", 0);
+ } else {
+ *arg_val = lydict_insert(ctx->xml_ctx.ctx, iter->content, iter->content_len);
+ LY_CHECK_RET(!(*arg_val), LY_EMEM);
+ }
}
} else {
LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LYVE_SYNTAX_YIN, "Unexpected attribute \"%.*s\" of %s element.", iter->name_len, iter->name, ly_stmt2str(current_element));
@@ -1202,7 +1206,7 @@
}
} else {
if (out_len == 0) {
- *text_content = NULL;
+ *text_content = lydict_insert(ctx->xml_ctx.ctx, "", 0);
} else {
*text_content = lydict_insert(ctx->xml_ctx.ctx, out, out_len);
}