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

- valid.c tree.c parserInternals.c parser.c: Stephan Kulow

provided another failing case found in KDE, the way the
  ctxt->vctxt.nodeTab was allocated and freed changed over
  time but it wasn't completely cleaned up. This should fix it.
Daniel
This commit is contained in:
Daniel Veillard
2001-06-19 11:07:54 +00:00
parent 3ed27bdef0
commit a9142e74c5
5 changed files with 24 additions and 17 deletions

View File

@ -1,3 +1,10 @@
Tue Jun 19 13:04:10 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* valid.c tree.c parserInternals.c parser.c: Stephan Kulow
provided another failing case found in KDE, the way the
ctxt->vctxt.nodeTab was allocated and freed changed over
time but it wasn't completely cleaned up. This should fix it.
Sun Jun 17 19:56:33 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr> Sun Jun 17 19:56:33 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* parser.c: Stephan Kulow also raised the fact that line number * parser.c: Stephan Kulow also raised the fact that line number

View File

@ -8853,23 +8853,14 @@ xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx, const xmlChar *URL,
if (ctxt->validate) { if (ctxt->validate) {
ctxt->vctxt.error = ctx->vctxt.error; ctxt->vctxt.error = ctx->vctxt.error;
ctxt->vctxt.warning = ctx->vctxt.warning; ctxt->vctxt.warning = ctx->vctxt.warning;
/* Allocate the Node stack */
ctxt->vctxt.nodeTab = (xmlNodePtr *) xmlMalloc(4 * sizeof(xmlNodePtr));
if (ctxt->vctxt.nodeTab == NULL) {
xmlGenericError(xmlGenericErrorContext,
"xmlParseCtxtExternalEntity: out of memory\n");
ctxt->validate = 0;
ctxt->vctxt.error = NULL;
ctxt->vctxt.warning = NULL;
} else {
ctxt->vctxt.nodeNr = 0;
ctxt->vctxt.nodeMax = 4;
ctxt->vctxt.node = NULL;
}
} else { } else {
ctxt->vctxt.error = NULL; ctxt->vctxt.error = NULL;
ctxt->vctxt.warning = NULL; ctxt->vctxt.warning = NULL;
} }
ctxt->vctxt.nodeTab = NULL;
ctxt->vctxt.nodeNr = 0;
ctxt->vctxt.nodeMax = 0;
ctxt->vctxt.node = NULL;
xmlParseContent(ctxt); xmlParseContent(ctxt);

View File

@ -2264,6 +2264,7 @@ xmlFreeParserCtxt(xmlParserCtxtPtr ctxt)
if ((ctxt->sax != NULL) && (ctxt->sax != &xmlDefaultSAXHandler)) if ((ctxt->sax != NULL) && (ctxt->sax != &xmlDefaultSAXHandler))
xmlFree(ctxt->sax); xmlFree(ctxt->sax);
if (ctxt->directory != NULL) xmlFree((char *) ctxt->directory); if (ctxt->directory != NULL) xmlFree((char *) ctxt->directory);
if (ctxt->vctxt.nodeTab != NULL) xmlFree(ctxt->vctxt.nodeTab);
xmlFree(ctxt); xmlFree(ctxt);
} }

12
tree.c
View File

@ -483,6 +483,8 @@ xmlNewDoc(const xmlChar *version) {
*/ */
void void
xmlFreeDoc(xmlDocPtr cur) { xmlFreeDoc(xmlDocPtr cur) {
xmlDtdPtr extSubset, intSubset;
if (cur == NULL) { if (cur == NULL) {
#ifdef DEBUG_TREE #ifdef DEBUG_TREE
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
@ -497,15 +499,17 @@ xmlFreeDoc(xmlDocPtr cur) {
cur->ids = NULL; cur->ids = NULL;
if (cur->refs != NULL) xmlFreeRefTable((xmlRefTablePtr) cur->refs); if (cur->refs != NULL) xmlFreeRefTable((xmlRefTablePtr) cur->refs);
cur->refs = NULL; cur->refs = NULL;
if (cur->extSubset != NULL) { extSubset = cur->extSubset;
intSubset = cur->intSubset;
if (extSubset != NULL) {
xmlUnlinkNode((xmlNodePtr) cur->extSubset); xmlUnlinkNode((xmlNodePtr) cur->extSubset);
xmlFreeDtd(cur->extSubset);
cur->extSubset = NULL; cur->extSubset = NULL;
xmlFreeDtd(extSubset);
} }
if (cur->intSubset != NULL) { if (intSubset != NULL) {
xmlUnlinkNode((xmlNodePtr) cur->intSubset); xmlUnlinkNode((xmlNodePtr) cur->intSubset);
xmlFreeDtd(cur->intSubset);
cur->intSubset = NULL; cur->intSubset = NULL;
xmlFreeDtd(intSubset);
} }
if (cur->children != NULL) xmlFreeNodeList(cur->children); if (cur->children != NULL) xmlFreeNodeList(cur->children);

View File

@ -38,6 +38,7 @@ scope int name##VPush(xmlValidCtxtPtr ctxt, type value) { \
if (ctxt->name##Tab == NULL) { \ if (ctxt->name##Tab == NULL) { \
xmlGenericError(xmlGenericErrorContext, \ xmlGenericError(xmlGenericErrorContext, \
"malloc failed !\n"); \ "malloc failed !\n"); \
ctxt->name##Max = 0; \
return(0); \ return(0); \
} \ } \
} \ } \
@ -3699,6 +3700,8 @@ xmlValidateElementContent(xmlValidCtxtPtr ctxt, xmlNodePtr child,
/* /*
* The first entry in the stack is reserved to the current state * The first entry in the stack is reserved to the current state
*/ */
ctxt->nodeMax = 0;
ctxt->nodeNr = 0;
ctxt->nodeTab = NULL; ctxt->nodeTab = NULL;
ctxt->vstate = &ctxt->vstateTab[0]; ctxt->vstate = &ctxt->vstateTab[0];
ctxt->vstateNr = 1; ctxt->vstateNr = 1;
@ -3829,6 +3832,7 @@ done:
ctxt->vstateTab = NULL; ctxt->vstateTab = NULL;
} }
ctxt->nodeMax = 0; ctxt->nodeMax = 0;
ctxt->nodeNr = 0;
if (ctxt->nodeTab != NULL) { if (ctxt->nodeTab != NULL) {
xmlFree(ctxt->nodeTab); xmlFree(ctxt->nodeTab);
ctxt->nodeTab = NULL; ctxt->nodeTab = NULL;