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

Joe Marcus Clarke reported a segfault on FBsd this was due to

* valid.c: Joe Marcus Clarke reported a segfault on FBsd
  this was due to uninitialized parts of the validation context
Daniel
This commit is contained in:
Daniel Veillard
2002-10-09 10:20:30 +00:00
parent 321be0c5bf
commit 01992e0446
3 changed files with 24 additions and 8 deletions

View File

@ -1,3 +1,8 @@
Wed Oct 9 12:18:37 CEST 2002 Daniel Veillard <daniel@veillard.com>
* valid.c: Joe Marcus Clarke reported a segfault on FBsd
this was due to uninitialized parts of the validation context
Tue Oct 8 23:24:20 CEST 2002 Daniel Veillard <daniel@veillard.com> Tue Oct 8 23:24:20 CEST 2002 Daniel Veillard <daniel@veillard.com>
* debugXML.c: applied patch from Mark Vakoc except the API * debugXML.c: applied patch from Mark Vakoc except the API

View File

@ -1355,17 +1355,23 @@ xmlShellPrintXPathError(int errorType, const char *arg)
static void static void
xmlShellPrintNodeCtxt(xmlShellCtxtPtr ctxt,xmlNodePtr node) xmlShellPrintNodeCtxt(xmlShellCtxtPtr ctxt,xmlNodePtr node)
{ {
if (!ctxt || !node) FILE *fp;
if (!node)
return; return;
if (ctxt == NULL)
fp = stdout;
else
fp = ctxt->output;
if (node->type == XML_DOCUMENT_NODE) if (node->type == XML_DOCUMENT_NODE)
xmlDocDump(ctxt->output, (xmlDocPtr) node); xmlDocDump(fp, (xmlDocPtr) node);
else if (node->type == XML_ATTRIBUTE_NODE) else if (node->type == XML_ATTRIBUTE_NODE)
xmlDebugDumpAttrList(ctxt->output, (xmlAttrPtr) node, 0); xmlDebugDumpAttrList(fp, (xmlAttrPtr) node, 0);
else else
xmlElemDump(ctxt->output, node->doc, node); xmlElemDump(fp, node->doc, node);
fprintf(ctxt->output, "\n"); fprintf(fp, "\n");
} }
/** /**

11
valid.c
View File

@ -4552,9 +4552,9 @@ xmlValidateElementContent(xmlValidCtxtPtr ctxt, xmlNodePtr child,
xmlElementPtr elemDecl, int warn, xmlNodePtr parent) { xmlElementPtr elemDecl, int warn, xmlNodePtr parent) {
int ret = 1; int ret = 1;
#ifndef LIBXML_REGEXP_ENABLED #ifndef LIBXML_REGEXP_ENABLED
xmlNodePtr last = NULL; xmlNodePtr repl = NULL, last = NULL, tmp;
#endif #endif
xmlNodePtr repl = NULL, cur, tmp; xmlNodePtr cur;
xmlElementContentPtr cont; xmlElementContentPtr cont;
const xmlChar *name; const xmlChar *name;
@ -4572,6 +4572,9 @@ xmlValidateElementContent(xmlValidCtxtPtr ctxt, xmlNodePtr child,
} else { } else {
xmlRegExecCtxtPtr exec; xmlRegExecCtxtPtr exec;
ctxt->nodeMax = 0;
ctxt->nodeNr = 0;
ctxt->nodeTab = NULL;
exec = xmlRegNewExecCtxt(elemDecl->contModel, NULL, NULL); exec = xmlRegNewExecCtxt(elemDecl->contModel, NULL, NULL);
if (exec != NULL) { if (exec != NULL) {
cur = child; cur = child;
@ -4763,9 +4766,11 @@ fail:
expr[0] = 0; expr[0] = 0;
xmlSnprintfElementContent(expr, 5000, cont, 1); xmlSnprintfElementContent(expr, 5000, cont, 1);
list[0] = 0; list[0] = 0;
#ifndef LIBXML_REGEXP_ENABLED
if (repl != NULL) if (repl != NULL)
xmlSnprintfElements(list, 5000, repl, 1); xmlSnprintfElements(list, 5000, repl, 1);
else else
#endif /* LIBXML_REGEXP_ENABLED */
xmlSnprintfElements(list, 5000, child, 1); xmlSnprintfElements(list, 5000, child, 1);
if (name != NULL) { if (name != NULL) {
@ -4798,7 +4803,6 @@ fail:
#ifndef LIBXML_REGEXP_ENABLED #ifndef LIBXML_REGEXP_ENABLED
done: done:
#endif
/* /*
* Deallocate the copy if done, and free up the validation stack * Deallocate the copy if done, and free up the validation stack
*/ */
@ -4812,6 +4816,7 @@ done:
xmlFree(ctxt->vstateTab); xmlFree(ctxt->vstateTab);
ctxt->vstateTab = NULL; ctxt->vstateTab = NULL;
} }
#endif
ctxt->nodeMax = 0; ctxt->nodeMax = 0;
ctxt->nodeNr = 0; ctxt->nodeNr = 0;
if (ctxt->nodeTab != NULL) { if (ctxt->nodeTab != NULL) {