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

parser: Only set input ID for PE refs

Other input streams don't require IDs.
This commit is contained in:
Nick Wellnhofer
2024-06-11 00:55:38 +02:00
parent a3b2baeb67
commit 410931e385
2 changed files with 8 additions and 13 deletions

View File

@@ -7850,12 +7850,20 @@ xmlParsePEReference(xmlParserCtxtPtr ctxt)
return;
}
if (ctxt->input_id >= INT_MAX) {
xmlFatalErr(ctxt, XML_ERR_RESOURCE_LIMIT,
"Input ID overflow\n");
return;
}
input = xmlNewEntityInputStream(ctxt, entity);
if (xmlPushInput(ctxt, input) < 0) {
xmlFreeInputStream(input);
return;
}
input->id = ++ctxt->input_id;
entity->flags |= XML_ENT_EXPANDING;
if (entity->etype == XML_EXTERNAL_PARAMETER_ENTITY) {

View File

@@ -1509,19 +1509,6 @@ xmlNewInputStream(xmlParserCtxtPtr ctxt) {
input->line = 1;
input->col = 1;
/*
* If the context is NULL the id cannot be initialized, but that
* should not happen while parsing which is the situation where
* the id is actually needed.
*/
if (ctxt != NULL) {
if (input->id >= INT_MAX) {
xmlCtxtErrMemory(ctxt);
return(NULL);
}
input->id = ctxt->input_id++;
}
return(input);
}