1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-29 11:41:22 +03:00

Fixing two stupid bugs on entities and HTML tree deallocation, Daniel.

This commit is contained in:
Daniel Veillard
1999-09-01 12:19:13 +00:00
parent e7a5a77dd0
commit 1ff7ae3dfd
3 changed files with 56 additions and 4 deletions

View File

@ -1,4 +1,12 @@
Mon Aug 30 13:22:26 CEST 1999 Wed Sep 1 14:15:09 CEST 1999 Daniel Veillard <Daniel.Veillard@w3.org>
* HTMLparser.c: corrected a stupid bug leading to core dump at
tree deallocation. Removed warnings indicated by
Stephane.Conversy@lri.fr
* entities.c: Fixes Yet Another Stupid Bug, entities were not
looked for in the external subset
Mon Aug 30 13:22:26 CEST 1999 Daniel Veillard <Daniel.Veillard@w3.org>
* parser.c valid.[ch] xpath.c: patched compilation warnings reported * parser.c valid.[ch] xpath.c: patched compilation warnings reported
on SGI by Stephane.Conversy@lri.fr on SGI by Stephane.Conversy@lri.fr

View File

@ -2220,18 +2220,22 @@ void
htmlParseElement(htmlParserCtxtPtr ctxt) { htmlParseElement(htmlParserCtxtPtr ctxt) {
const CHAR *openTag = CUR_PTR; const CHAR *openTag = CUR_PTR;
CHAR *name; CHAR *name;
htmlParserNodeInfo node_info;
htmlNodePtr currentNode; htmlNodePtr currentNode;
htmlElemDescPtr info; htmlElemDescPtr info;
htmlParserNodeInfo node_info;
/* Capture start position */ /* Capture start position */
node_info.begin_pos = CUR_PTR - ctxt->input->base; if (ctxt->record_info) {
node_info.begin_pos = ctxt->input->consumed +
(CUR_PTR - ctxt->input->base);
node_info.begin_line = ctxt->input->line; node_info.begin_line = ctxt->input->line;
}
name = htmlParseStartTag(ctxt); name = htmlParseStartTag(ctxt);
if (name == NULL) { if (name == NULL) {
return; return;
} }
currentNode = ctxt->node;
/* /*
* Lookup the info for that element. * Lookup the info for that element.
@ -2274,6 +2278,17 @@ htmlParseElement(htmlParserCtxtPtr ctxt) {
*/ */
nodePop(ctxt); nodePop(ctxt);
free(name); free(name);
/*
* Capture end position and add node
*/
if ( currentNode != NULL && ctxt->record_info ) {
node_info.end_pos = ctxt->input->consumed +
(CUR_PTR - ctxt->input->base);
node_info.end_line = ctxt->input->line;
node_info.node = currentNode;
xmlParserAddNodeInfo(ctxt, &node_info);
}
return; return;
} }
@ -2317,6 +2332,17 @@ htmlParseElement(htmlParserCtxtPtr ctxt) {
} }
free(name); free(name);
/*
* Capture end position and add node
*/
if ( currentNode != NULL && ctxt->record_info ) {
node_info.end_pos = ctxt->input->consumed +
(CUR_PTR - ctxt->input->base);
node_info.end_line = ctxt->input->line;
node_info.node = currentNode;
xmlParserAddNodeInfo(ctxt, &node_info);
}
} }
/** /**

View File

@ -260,6 +260,15 @@ xmlGetParameterEntity(xmlDocPtr doc, const CHAR *name) {
(!xmlStrcmp(cur->name, name))) return(cur); (!xmlStrcmp(cur->name, name))) return(cur);
} }
} }
if ((doc->extSubset != NULL) && (doc->extSubset->entities != NULL)) {
table = (xmlEntitiesTablePtr) doc->extSubset->entities;
for (i = 0;i < table->nb_entities;i++) {
cur = &table->table[i];
if (((cur->type == XML_INTERNAL_PARAMETER_ENTITY) ||
(cur->type == XML_EXTERNAL_PARAMETER_ENTITY)) &&
(!xmlStrcmp(cur->name, name))) return(cur);
}
}
return(NULL); return(NULL);
} }
@ -317,6 +326,15 @@ xmlGetDocEntity(xmlDocPtr doc, const CHAR *name) {
(!xmlStrcmp(cur->name, name))) return(cur); (!xmlStrcmp(cur->name, name))) return(cur);
} }
} }
if ((doc->extSubset != NULL) && (doc->extSubset->entities != NULL)) {
table = (xmlEntitiesTablePtr) doc->extSubset->entities;
for (i = 0;i < table->nb_entities;i++) {
cur = &table->table[i];
if ((cur->type != XML_INTERNAL_PARAMETER_ENTITY) &&
(cur->type != XML_EXTERNAL_PARAMETER_ENTITY) &&
(!xmlStrcmp(cur->name, name))) return(cur);
}
}
if (xmlPredefinedEntities == NULL) if (xmlPredefinedEntities == NULL)
xmlInitializePredefinedEntities(); xmlInitializePredefinedEntities();
table = xmlPredefinedEntities; table = xmlPredefinedEntities;