mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-24 13:33:01 +03:00
parser: Report malloc failure in xmlNewInputFromFile
This commit is contained in:
@@ -2033,7 +2033,8 @@ xmlParserInputPtr
|
|||||||
xmlNewInputFromFile(xmlParserCtxtPtr ctxt, const char *filename) {
|
xmlNewInputFromFile(xmlParserCtxtPtr ctxt, const char *filename) {
|
||||||
xmlParserInputBufferPtr buf;
|
xmlParserInputBufferPtr buf;
|
||||||
xmlParserInputPtr inputStream;
|
xmlParserInputPtr inputStream;
|
||||||
xmlChar *URI = NULL;
|
const xmlChar *URI;
|
||||||
|
xmlChar *canonic;
|
||||||
int code;
|
int code;
|
||||||
|
|
||||||
if ((ctxt == NULL) || (filename == NULL))
|
if ((ctxt == NULL) || (filename == NULL))
|
||||||
@@ -2058,12 +2059,18 @@ xmlNewInputFromFile(xmlParserCtxtPtr ctxt, const char *filename) {
|
|||||||
return(NULL);
|
return(NULL);
|
||||||
|
|
||||||
if (inputStream->filename == NULL)
|
if (inputStream->filename == NULL)
|
||||||
URI = xmlStrdup((xmlChar *) filename);
|
URI = (xmlChar *) filename;
|
||||||
else
|
else
|
||||||
URI = xmlStrdup((xmlChar *) inputStream->filename);
|
URI = (xmlChar *) inputStream->filename;
|
||||||
if (inputStream->filename != NULL) xmlFree((char *)inputStream->filename);
|
canonic = xmlCanonicPath(URI);
|
||||||
inputStream->filename = (char *) xmlCanonicPath((const xmlChar *) URI);
|
if (canonic == NULL) {
|
||||||
if (URI != NULL) xmlFree((char *) URI);
|
xmlCtxtErrMemory(ctxt);
|
||||||
|
xmlFreeInputStream(inputStream);
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
if (inputStream->filename != NULL)
|
||||||
|
xmlFree((char *) inputStream->filename);
|
||||||
|
inputStream->filename = (char *) canonic;
|
||||||
|
|
||||||
xmlBufResetInput(inputStream->buf->buffer, inputStream);
|
xmlBufResetInput(inputStream->buf->buffer, inputStream);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user