mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-03-21 22:50:08 +03:00
parser: Fix initialization of namespace data
Move initialization to xmlInitSAXParserCtxt. Also add missing XML_HIDDEN to xmlParserNsFree. Fixes #597.
This commit is contained in:
parent
fc49679316
commit
eb69c1d39d
@ -49,12 +49,14 @@ xmlDetectEncoding(xmlParserCtxtPtr ctxt);
|
||||
XML_HIDDEN void
|
||||
xmlSetDeclaredEncoding(xmlParserCtxtPtr ctxt, xmlChar *encoding);
|
||||
|
||||
XML_HIDDEN xmlParserNsData *
|
||||
xmlParserNsCreate(void);
|
||||
XML_HIDDEN void
|
||||
xmlParserNsFree(xmlParserNsData *nsdb);
|
||||
/*
|
||||
* These functions allow SAX handlers to attach extra data to namespaces
|
||||
* efficiently and should be made public.
|
||||
*/
|
||||
void
|
||||
xmlParserNsFree(xmlParserNsData *nsdb);
|
||||
XML_HIDDEN int
|
||||
xmlParserNsUpdateSax(xmlParserCtxtPtr ctxt, const xmlChar *prefix,
|
||||
void *saxData);
|
||||
|
15
parser.c
15
parser.c
@ -1397,7 +1397,7 @@ static xmlEntityPtr xmlParseStringEntityRef(xmlParserCtxtPtr ctxt,
|
||||
*
|
||||
* Returns the new obejct.
|
||||
*/
|
||||
static xmlParserNsData *
|
||||
xmlParserNsData *
|
||||
xmlParserNsCreate(void) {
|
||||
xmlParserNsData *nsdb = xmlMalloc(sizeof(*nsdb));
|
||||
|
||||
@ -9473,14 +9473,6 @@ xmlParseStartTag2(xmlParserCtxtPtr ctxt, const xmlChar **pref,
|
||||
nbNs = 0;
|
||||
attval = 0;
|
||||
|
||||
if (ctxt->nsdb == NULL) {
|
||||
ctxt->nsdb = xmlParserNsCreate();
|
||||
if (ctxt->nsdb == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if (xmlParserNsStartElement(ctxt->nsdb) < 0) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
return(NULL);
|
||||
@ -12916,11 +12908,6 @@ xmlParseBalancedChunkMemoryInternal(xmlParserCtxtPtr oldctxt,
|
||||
|
||||
/* propagate namespaces down the entity */
|
||||
if (oldctxt->nsdb != NULL) {
|
||||
ctxt->nsdb = xmlParserNsCreate();
|
||||
if (ctxt->nsdb == NULL) {
|
||||
ret = XML_ERR_NO_MEMORY;
|
||||
goto error;
|
||||
}
|
||||
for (i = 0; i < oldctxt->nsdb->hashSize; i++) {
|
||||
xmlParserNsBucket *bucket = &oldctxt->nsdb->hash[i];
|
||||
xmlHashedString hprefix, huri;
|
||||
|
@ -2002,6 +2002,15 @@ xmlInitSAXParserCtxt(xmlParserCtxtPtr ctxt, const xmlSAXHandler *sax,
|
||||
ctxt->input_id = 1;
|
||||
ctxt->maxAmpl = XML_MAX_AMPLIFICATION_DEFAULT;
|
||||
xmlInitNodeInfoSeq(&ctxt->node_seq);
|
||||
|
||||
if (ctxt->nsdb == NULL) {
|
||||
ctxt->nsdb = xmlParserNsCreate();
|
||||
if (ctxt->nsdb == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user