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