Skip to content
This repository was archived by the owner on Jan 26, 2026. It is now read-only.

Commit aaa24ca

Browse files
committed
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.
1 parent 48dba1e commit aaa24ca

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

uri.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2018,6 +2018,18 @@ xmlBuildURISafe(const xmlChar *URI, const xmlChar *base, xmlChar **valPtr) {
20182018

20192019
if (valPtr == NULL)
20202020
return(1);
2021+
*valPtr = NULL;
2022+
2023+
if (URI == NULL)
2024+
return(1);
2025+
2026+
if (base == NULL) {
2027+
val = xmlStrdup(URI);
2028+
if (val == NULL)
2029+
return(-1);
2030+
*valPtr = val;
2031+
return(0);
2032+
}
20212033

20222034
/*
20232035
* 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) {
20272039
* as a reference to "." rather than as a synonym for the current
20282040
* URI. Should we do that here?
20292041
*/
2030-
if (URI == NULL)
2031-
ret = 1;
2032-
else if (URI[0] != 0)
2042+
if (URI[0] != 0)
20332043
ret = xmlParseURISafe((const char *) URI, &ref);
20342044
else
20352045
ret = 0;

0 commit comments

Comments
 (0)