mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2024-10-26 12:25:09 +03:00
Null pointer handling in catalog.c
Fix potential deferencing potential null pointers; Small optimizations. Closes #123.
This commit is contained in:
parent
29740ed12f
commit
d724861536
14
catalog.c
14
catalog.c
@ -924,7 +924,7 @@ xmlParseCatalogFile(const char *filename) {
|
||||
xmlBufResetInput(buf->buffer, inputStream);
|
||||
|
||||
inputPush(ctxt, inputStream);
|
||||
if ((ctxt->directory == NULL) && (directory == NULL))
|
||||
if (ctxt->directory == NULL)
|
||||
directory = xmlParserGetDirectory(filename);
|
||||
if ((ctxt->directory == NULL) && (directory != NULL))
|
||||
ctxt->directory = directory;
|
||||
@ -2069,8 +2069,7 @@ xmlCatalogListXMLResolve(xmlCatalogEntryPtr catal, const xmlChar *pubID,
|
||||
ret = xmlCatalogXMLResolve(catal->children, pubID, sysID);
|
||||
if (ret != NULL) {
|
||||
break;
|
||||
} else if ((catal->children != NULL) &&
|
||||
(catal->children->depth > MAX_CATAL_DEPTH)) {
|
||||
} else if (catal->children->depth > MAX_CATAL_DEPTH) {
|
||||
ret = NULL;
|
||||
break;
|
||||
}
|
||||
@ -2353,7 +2352,7 @@ xmlParseSGMLCatalog(xmlCatalogPtr catal, const xmlChar *value,
|
||||
xmlCatalogEntryType type = XML_CATA_NONE;
|
||||
|
||||
cur = xmlParseSGMLCatalogName(cur, &name);
|
||||
if (name == NULL) {
|
||||
if (cur == NULL || name == NULL) {
|
||||
/* error */
|
||||
break;
|
||||
}
|
||||
@ -3254,6 +3253,7 @@ xmlLoadCatalogs(const char *pathss) {
|
||||
while ((*cur != 0) && (*cur != PATH_SEPARATOR) && (!xmlIsBlank_ch(*cur)))
|
||||
cur++;
|
||||
path = xmlStrndup((const xmlChar *)paths, cur - paths);
|
||||
if (path != NULL) {
|
||||
#ifdef _WIN32
|
||||
iLen = strlen((const char*)path);
|
||||
for(i = 0; i < iLen; i++) {
|
||||
@ -3262,7 +3262,6 @@ xmlLoadCatalogs(const char *pathss) {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (path != NULL) {
|
||||
xmlLoadCatalog((const char *) path);
|
||||
xmlFree(path);
|
||||
}
|
||||
@ -3427,9 +3426,10 @@ xmlCatalogAdd(const xmlChar *type, const xmlChar *orig, const xmlChar *replace)
|
||||
(xmlStrEqual(type, BAD_CAST "catalog"))) {
|
||||
xmlDefaultCatalog = xmlCreateNewCatalog(XML_XML_CATALOG_TYPE,
|
||||
xmlCatalogDefaultPrefer);
|
||||
xmlDefaultCatalog->xml = xmlNewCatalogEntry(XML_CATA_CATALOG, NULL,
|
||||
if (xmlDefaultCatalog != NULL) {
|
||||
xmlDefaultCatalog->xml = xmlNewCatalogEntry(XML_CATA_CATALOG, NULL,
|
||||
orig, NULL, xmlCatalogDefaultPrefer, NULL);
|
||||
|
||||
}
|
||||
xmlRMutexUnlock(xmlCatalogMutex);
|
||||
return(0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user