[LIBXML2] Update to version 2.9.12. CORE-17766

This commit is contained in:
Thomas Faber 2021-09-12 13:24:24 -04:00
parent 271556e6f8
commit 40ee59d609
No known key found for this signature in database
GPG key ID: 076E7C3D44720826
60 changed files with 3385 additions and 2832 deletions

View file

@ -70,7 +70,7 @@
/**
* xmlXPtrErrMemory:
* @extra: extra informations
* @extra: extra information
*
* Handle a redefinition of attribute error
*/
@ -86,7 +86,7 @@ xmlXPtrErrMemory(const char *extra)
/**
* xmlXPtrErr:
* @ctxt: an XPTR evaluation context
* @extra: extra informations
* @extra: extra information
*
* Handle a redefinition of attribute error
*/
@ -1005,7 +1005,7 @@ xmlXPtrEvalXPtrPart(xmlXPathParserContextPtr ctxt, xmlChar *name) {
/*
* To evaluate an xpointer scheme element (4.3) we need:
* context initialized to the root
* context position initalized to 1
* context position initialized to 1
* context size initialized to 1
*/
ctxt->context->node = (xmlNodePtr)ctxt->context->doc;
@ -1352,7 +1352,7 @@ xmlXPtrEval(const xmlChar *str, xmlXPathContextPtr ctx) {
xmlXPathObjectPtr init = NULL;
int stack = 0;
xmlXPathInit();
xmlInitParser();
if ((ctx == NULL) || (str == NULL))
return(NULL);
@ -1536,7 +1536,7 @@ xmlXPtrBuildRangeNodeList(xmlXPathObjectPtr range) {
case XML_ELEMENT_DECL:
case XML_ATTRIBUTE_DECL:
case XML_ENTITY_NODE:
/* Do not copy DTD informations */
/* Do not copy DTD information */
break;
case XML_ENTITY_DECL:
TODO /* handle crossing entities -> stack needed */
@ -2200,7 +2200,6 @@ xmlXPtrRangeInsideFunction(xmlXPathParserContextPtr ctxt, int nargs) {
XP_ERROR(XPATH_MEMORY_ERROR)
set = tmp;
}
oldset = (xmlLocationSetPtr) set->user;
/*
* The loop is to compute the covering range for each item and add it
@ -2210,9 +2209,12 @@ xmlXPtrRangeInsideFunction(xmlXPathParserContextPtr ctxt, int nargs) {
xmlXPathFreeObject(set);
XP_ERROR(XPATH_MEMORY_ERROR);
}
for (i = 0;i < oldset->locNr;i++) {
xmlXPtrLocationSetAdd(newset,
xmlXPtrInsideRange(ctxt, oldset->locTab[i]));
oldset = (xmlLocationSetPtr) set->user;
if (oldset != NULL) {
for (i = 0;i < oldset->locNr;i++) {
xmlXPtrLocationSetAdd(newset,
xmlXPtrInsideRange(ctxt, oldset->locTab[i]));
}
}
/*
@ -2706,10 +2708,10 @@ static void
xmlXPtrStringRangeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
int i, startindex, endindex = 0, fendindex;
xmlNodePtr start, end = 0, fend;
xmlXPathObjectPtr set;
xmlXPathObjectPtr set = NULL;
xmlLocationSetPtr oldset;
xmlLocationSetPtr newset;
xmlXPathObjectPtr string;
xmlLocationSetPtr newset = NULL;
xmlXPathObjectPtr string = NULL;
xmlXPathObjectPtr position = NULL;
xmlXPathObjectPtr number = NULL;
int found, pos = 0, num = 0;
@ -2721,29 +2723,39 @@ xmlXPtrStringRangeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
XP_ERROR(XPATH_INVALID_ARITY);
if (nargs >= 4) {
CHECK_TYPE(XPATH_NUMBER);
if ((ctxt->value == NULL) || (ctxt->value->type != XPATH_NUMBER)) {
xmlXPathErr(ctxt, XPATH_INVALID_TYPE);
goto error;
}
number = valuePop(ctxt);
if (number != NULL)
num = (int) number->floatval;
}
if (nargs >= 3) {
CHECK_TYPE(XPATH_NUMBER);
if ((ctxt->value == NULL) || (ctxt->value->type != XPATH_NUMBER)) {
xmlXPathErr(ctxt, XPATH_INVALID_TYPE);
goto error;
}
position = valuePop(ctxt);
if (position != NULL)
pos = (int) position->floatval;
}
CHECK_TYPE(XPATH_STRING);
if ((ctxt->value == NULL) || (ctxt->value->type != XPATH_STRING)) {
xmlXPathErr(ctxt, XPATH_INVALID_TYPE);
goto error;
}
string = valuePop(ctxt);
if ((ctxt->value == NULL) ||
((ctxt->value->type != XPATH_LOCATIONSET) &&
(ctxt->value->type != XPATH_NODESET)))
XP_ERROR(XPATH_INVALID_TYPE)
(ctxt->value->type != XPATH_NODESET))) {
xmlXPathErr(ctxt, XPATH_INVALID_TYPE);
goto error;
}
set = valuePop(ctxt);
newset = xmlXPtrLocationSetCreate(NULL);
if (newset == NULL) {
xmlXPathFreeObject(set);
XP_ERROR(XPATH_MEMORY_ERROR);
xmlXPathErr(ctxt, XPATH_MEMORY_ERROR);
goto error;
}
if (set->nodesetval == NULL) {
goto error;
@ -2756,8 +2768,10 @@ xmlXPtrStringRangeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
*/
tmp = xmlXPtrNewLocationSetNodeSet(set->nodesetval);
xmlXPathFreeObject(set);
if (tmp == NULL)
XP_ERROR(XPATH_MEMORY_ERROR)
if (tmp == NULL) {
xmlXPathErr(ctxt, XPATH_MEMORY_ERROR);
goto error;
}
set = tmp;
}
oldset = (xmlLocationSetPtr) set->user;
@ -2830,7 +2844,8 @@ xmlXPtrStringRangeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
* Save the new value and cleanup
*/
error:
valuePush(ctxt, xmlXPtrWrapLocationSet(newset));
if (newset != NULL)
valuePush(ctxt, xmlXPtrWrapLocationSet(newset));
xmlXPathFreeObject(set);
xmlXPathFreeObject(string);
if (position) xmlXPathFreeObject(position);