mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-26 00:37:43 +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:
@@ -49,12 +49,14 @@ xmlDetectEncoding(xmlParserCtxtPtr ctxt);
|
|||||||
XML_HIDDEN void
|
XML_HIDDEN void
|
||||||
xmlSetDeclaredEncoding(xmlParserCtxtPtr ctxt, xmlChar *encoding);
|
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
|
* These functions allow SAX handlers to attach extra data to namespaces
|
||||||
* efficiently and should be made public.
|
* efficiently and should be made public.
|
||||||
*/
|
*/
|
||||||
void
|
|
||||||
xmlParserNsFree(xmlParserNsData *nsdb);
|
|
||||||
XML_HIDDEN int
|
XML_HIDDEN int
|
||||||
xmlParserNsUpdateSax(xmlParserCtxtPtr ctxt, const xmlChar *prefix,
|
xmlParserNsUpdateSax(xmlParserCtxtPtr ctxt, const xmlChar *prefix,
|
||||||
void *saxData);
|
void *saxData);
|
||||||
|
|||||||
15
parser.c
15
parser.c
@@ -1397,7 +1397,7 @@ static xmlEntityPtr xmlParseStringEntityRef(xmlParserCtxtPtr ctxt,
|
|||||||
*
|
*
|
||||||
* Returns the new obejct.
|
* Returns the new obejct.
|
||||||
*/
|
*/
|
||||||
static xmlParserNsData *
|
xmlParserNsData *
|
||||||
xmlParserNsCreate(void) {
|
xmlParserNsCreate(void) {
|
||||||
xmlParserNsData *nsdb = xmlMalloc(sizeof(*nsdb));
|
xmlParserNsData *nsdb = xmlMalloc(sizeof(*nsdb));
|
||||||
|
|
||||||
@@ -9473,14 +9473,6 @@ xmlParseStartTag2(xmlParserCtxtPtr ctxt, const xmlChar **pref,
|
|||||||
nbNs = 0;
|
nbNs = 0;
|
||||||
attval = 0;
|
attval = 0;
|
||||||
|
|
||||||
if (ctxt->nsdb == NULL) {
|
|
||||||
ctxt->nsdb = xmlParserNsCreate();
|
|
||||||
if (ctxt->nsdb == NULL) {
|
|
||||||
xmlErrMemory(ctxt, NULL);
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (xmlParserNsStartElement(ctxt->nsdb) < 0) {
|
if (xmlParserNsStartElement(ctxt->nsdb) < 0) {
|
||||||
xmlErrMemory(ctxt, NULL);
|
xmlErrMemory(ctxt, NULL);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
@@ -12916,11 +12908,6 @@ xmlParseBalancedChunkMemoryInternal(xmlParserCtxtPtr oldctxt,
|
|||||||
|
|
||||||
/* propagate namespaces down the entity */
|
/* propagate namespaces down the entity */
|
||||||
if (oldctxt->nsdb != NULL) {
|
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++) {
|
for (i = 0; i < oldctxt->nsdb->hashSize; i++) {
|
||||||
xmlParserNsBucket *bucket = &oldctxt->nsdb->hash[i];
|
xmlParserNsBucket *bucket = &oldctxt->nsdb->hash[i];
|
||||||
xmlHashedString hprefix, huri;
|
xmlHashedString hprefix, huri;
|
||||||
|
|||||||
@@ -2002,6 +2002,15 @@ xmlInitSAXParserCtxt(xmlParserCtxtPtr ctxt, const xmlSAXHandler *sax,
|
|||||||
ctxt->input_id = 1;
|
ctxt->input_id = 1;
|
||||||
ctxt->maxAmpl = XML_MAX_AMPLIFICATION_DEFAULT;
|
ctxt->maxAmpl = XML_MAX_AMPLIFICATION_DEFAULT;
|
||||||
xmlInitNodeInfoSeq(&ctxt->node_seq);
|
xmlInitNodeInfoSeq(&ctxt->node_seq);
|
||||||
|
|
||||||
|
if (ctxt->nsdb == NULL) {
|
||||||
|
ctxt->nsdb = xmlParserNsCreate();
|
||||||
|
if (ctxt->nsdb == NULL) {
|
||||||
|
xmlErrMemory(ctxt, NULL);
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user