1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-12-23 17:33:50 +03:00

uri: Fix xmlBuildURI with NULL base

Don't try to parse URI if base is NULL. Fixes functions like xmlParseDTD
with certain filenames.

Should fix #742.
This commit is contained in:
Nick Wellnhofer 2024-06-20 21:06:38 +02:00
parent 1dd5e76a69
commit 4c3d22b059

16
uri.c
View File

@ -2018,6 +2018,18 @@ xmlBuildURISafe(const xmlChar *URI, const xmlChar *base, xmlChar **valPtr) {
if (valPtr == NULL)
return(1);
*valPtr = NULL;
if (URI == NULL)
return(1);
if (base == NULL) {
val = xmlStrdup(URI);
if (val == NULL)
return(-1);
*valPtr = val;
return(0);
}
/*
* 1) The URI reference is parsed into the potential four components and
@ -2027,9 +2039,7 @@ xmlBuildURISafe(const xmlChar *URI, const xmlChar *base, xmlChar **valPtr) {
* as a reference to "." rather than as a synonym for the current
* URI. Should we do that here?
*/
if (URI == NULL)
ret = 1;
else if (URI[0] != 0)
if (URI[0] != 0)
ret = xmlParseURISafe((const char *) URI, &ref);
else
ret = 0;