1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-10-24 13:33:01 +03:00

parser: Check return value of inputPush

inputPush typically doesn't fail because we pre-allocate the input
table. The return value should be checked nevertheless.
This commit is contained in:
Nick Wellnhofer
2024-07-07 19:21:46 +02:00
parent ea31ac5bba
commit 2e63656ec6
6 changed files with 76 additions and 17 deletions

View File

@@ -5033,7 +5033,11 @@ htmlCreateMemoryParserCtxtInternal(const char *url,
return(NULL);
}
inputPush(ctxt, input);
if (inputPush(ctxt, input) < 0) {
xmlFreeInputStream(input);
xmlFreeParserCtxt(ctxt);
return(NULL);
}
return(ctxt);
}
@@ -5086,7 +5090,11 @@ htmlCreateDocParserCtxt(const xmlChar *str, const char *url,
return(NULL);
}
inputPush(ctxt, input);
if (inputPush(ctxt, input) < 0) {
xmlFreeInputStream(input);
xmlFreeParserCtxt(ctxt);
return(NULL);
}
return(ctxt);
}
@@ -5815,7 +5823,11 @@ htmlCreatePushParserCtxt(htmlSAXHandlerPtr sax, void *user_data,
return(NULL);
}
inputPush(ctxt, input);
if (inputPush(ctxt, input) < 0) {
xmlFreeInputStream(input);
xmlFreeParserCtxt(ctxt);
return(NULL);
}
if (encoding != NULL)
xmlSwitchEncodingName(ctxt, encoding);
@@ -5921,7 +5933,11 @@ htmlCreateFileParserCtxt(const char *filename, const char *encoding)
xmlFreeParserCtxt(ctxt);
return(NULL);
}
inputPush(ctxt, input);
if (inputPush(ctxt, input) < 0) {
xmlFreeInputStream(input);
xmlFreeParserCtxt(ctxt);
return(NULL);
}
return(ctxt);
}