libyang MAINTAINCE fix change dynamic to static xml value allocation in parser
diff --git a/src/parser_xml.c b/src/parser_xml.c
index d01fdcd..40fda2f 100644
--- a/src/parser_xml.c
+++ b/src/parser_xml.c
@@ -485,6 +485,11 @@
if (xmlctx->ws_only) {
/* ignore WS-only value */
+ if (xmlctx->dynamic) {
+ free((char *) xmlctx->value);
+ }
+ xmlctx->dynamic = 0;
+ xmlctx->value = "";
xmlctx->value_len = 0;
format = LY_PREF_XML;
} else {
diff --git a/src/xml.c b/src/xml.c
index c4351bc..debfe90 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -615,9 +615,10 @@
/* store every namespace */
if ((prefix && !ly_strncmp("xmlns", prefix, prefix_len)) || (!prefix && !ly_strncmp("xmlns", name, name_len))) {
- LY_CHECK_GOTO(ret = lyxml_ns_add(xmlctx, prefix ? name : NULL, prefix ? name_len : 0,
- dynamic ? value : strndup(value, value_len)), cleanup);
+ ret = lyxml_ns_add(xmlctx, prefix ? name : NULL, prefix ? name_len : 0,
+ dynamic ? value : strndup(value, value_len));
dynamic = 0;
+ LY_CHECK_GOTO(ret, cleanup);
} else {
/* not a namespace */
is_ns = 0;
@@ -918,9 +919,13 @@
LY_CHECK_GOTO(ret, cleanup);
if (!xmlctx->value_len) {
+ /* empty value should by alocated staticaly, but check for in any case */
+ if (xmlctx->dynamic) {
+ free((char *) xmlctx->value);
+ }
/* use empty value, easier to work with */
xmlctx->value = "";
- assert(!xmlctx->dynamic);
+ xmlctx->dynamic = 0;
}
/* update status */