diff --git a/uri.c b/uri.c index 1e5e03f..807b183 100644 @@ -558,10 +558,14 @@ xmlParse3986PathAbEmpty(xmlURIPtr uri, const char **str) } if (uri != NULL) { if (uri->path != NULL) xmlFree(uri->path); - if (uri->cleanup & 2) - uri->path = STRNDUP(*str, cur - *str); - else - uri->path = xmlURIUnescapeString(*str, cur - *str, NULL); + if (*str != cur) { + if (uri->cleanup & 2) + uri->path = STRNDUP(*str, cur - *str); + else + uri->path = xmlURIUnescapeString(*str, cur - *str, NULL); + } else { + uri->path = NULL; + } } *str = cur; return (0); @@ -600,10 +604,14 @@ xmlParse3986PathAbsolute(xmlURIPtr uri, const char **str) } if (uri != NULL) { if (uri->path != NULL) xmlFree(uri->path); - if (uri->cleanup & 2) - uri->path = STRNDUP(*str, cur - *str); - else - uri->path = xmlURIUnescapeString(*str, cur - *str, NULL); + if (cur != *str) { + if (uri->cleanup & 2) + uri->path = STRNDUP(*str, cur - *str); + else + uri->path = xmlURIUnescapeString(*str, cur - *str, NULL); + } else { + uri->path = NULL; + } } *str = cur; return (0); @@ -638,10 +646,14 @@ xmlParse3986PathRootless(xmlURIPtr uri, const char **str) } if (uri != NULL) { if (uri->path != NULL) xmlFree(uri->path); - if (uri->cleanup & 2) - uri->path = STRNDUP(*str, cur - *str); - else - uri->path = xmlURIUnescapeString(*str, cur - *str, NULL); + if (cur != *str) { + if (uri->cleanup & 2) + uri->path = STRNDUP(*str, cur - *str); + else + uri->path = xmlURIUnescapeString(*str, cur - *str, NULL); + } else { + uri->path = NULL; + } } *str = cur; return (0); @@ -676,10 +688,14 @@ xmlParse3986PathNoScheme(xmlURIPtr uri, const char **str) } if (uri != NULL) { if (uri->path != NULL) xmlFree(uri->path); - if (uri->cleanup & 2) - uri->path = STRNDUP(*str, cur - *str); - else - uri->path = xmlURIUnescapeString(*str, cur - *str, NULL); + if (cur != *str) { + if (uri->cleanup & 2) + uri->path = STRNDUP(*str, cur - *str); + else + uri->path = xmlURIUnescapeString(*str, cur - *str, NULL); + } else { + uri->path = NULL; + } } *str = cur; return (0);