xml parser CHANGE don't expect null terminated string as uri in lyxml_ns_add
diff --git a/src/xml.c b/src/xml.c
index ccc0849..147170a 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -641,7 +641,7 @@
 }
 
 LY_ERR
-lyxml_ns_add(struct lyxml_context *context, const char *element_name, const char *prefix, size_t prefix_len, char *uri)
+lyxml_ns_add(struct lyxml_context *context, const char *element_name, const char *prefix, size_t prefix_len, char *uri, size_t uri_len)
 {
     struct lyxml_ns *ns;
 
@@ -649,15 +649,17 @@
     LY_CHECK_ERR_RET(!ns, LOGMEM(context->ctx), LY_EMEM);
 
     ns->element = element_name;
-    ns->uri = uri;
+    ns->uri = strndup(uri, uri_len);
+    LY_CHECK_ERR_RET(!ns->uri, LOGMEM(context->ctx); free(ns), LY_EMEM);
+
     if (prefix) {
         ns->prefix = strndup(prefix, prefix_len);
-        LY_CHECK_ERR_RET(!ns->prefix, LOGMEM(context->ctx); free(ns), LY_EMEM);
+        LY_CHECK_ERR_RET(!ns->prefix, LOGMEM(context->ctx); free(ns->uri); free(ns), LY_EMEM);
     } else {
         ns->prefix = NULL;
     }
 
-    LY_CHECK_ERR_RET(ly_set_add(&context->ns, ns, LY_SET_OPT_USEASLIST) == -1, free(ns->prefix), LY_EMEM);
+    LY_CHECK_ERR_RET(ly_set_add(&context->ns, ns, LY_SET_OPT_USEASLIST) == -1, free(ns->prefix); free(ns->uri); free(ns), LY_EMEM);
     return LY_SUCCESS;
 }
 
diff --git a/src/xml.h b/src/xml.h
index e12af7d..5c418fd 100644
--- a/src/xml.h
+++ b/src/xml.h
@@ -172,9 +172,10 @@
  * @param[in] prefix_len Length of the prefix string (since it is not NULL-terminated when returned from lyxml_get_attribute()).
  * @param[in] uri Namespace URI (value) to store. Value can be obtained via lyxml_get_string() and caller is not supposed to
  * work with the pointer when the function succeeds.
+ * @param[in] uri_len Lenght of the URI string (since it is not NULL-terminated when returned from lyxml_get_string())
  * @return LY_ERR values.
  */
-LY_ERR lyxml_ns_add(struct lyxml_context *context, const char *element_name, const char *prefix, size_t prefix_len, char *uri);
+LY_ERR lyxml_ns_add(struct lyxml_context *context, const char *element_name, const char *prefix, size_t prefix_len, char *uri, size_t uri_len);
 
 /**
  * @brief Get a namespace record for the given prefix in the current context.