1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-01-13 13:17:36 +03:00

tree: Fix reallocation in xmlDOMWrapNSNormAddNsMapItem2

This commit is contained in:
Nick Wellnhofer 2024-03-12 19:50:45 +01:00
parent e321eba0c7
commit ad019ba102

25
tree.c
View File

@ -7873,19 +7873,18 @@ static int
xmlDOMWrapNSNormAddNsMapItem2(xmlNsPtr **list, int *size, int *number,
xmlNsPtr oldNs, xmlNsPtr newNs)
{
if (*list == NULL) {
*list = (xmlNsPtr *) xmlMalloc(6 * sizeof(xmlNsPtr));
if (*list == NULL)
return(-1);
*size = 3;
*number = 0;
} else if ((*number) >= (*size)) {
*size *= 2;
*list = (xmlNsPtr *) xmlRealloc(*list,
(*size) * 2 * sizeof(xmlNsPtr));
if (*list == NULL)
return(-1);
if (*number >= *size) {
xmlNsPtr *tmp;
size_t newSize;
newSize = *size ? *size * 2 : 3;
tmp = xmlRealloc(*list, newSize * 2 * sizeof(tmp[0]));
if (tmp == NULL)
return(-1);
*list = tmp;
*size = newSize;
}
(*list)[2 * (*number)] = oldNs;
(*list)[2 * (*number) +1] = newNs;
(*number)++;
@ -7914,7 +7913,7 @@ xmlDOMWrapRemoveNode(xmlDOMWrapCtxtPtr ctxt, xmlDocPtr doc,
xmlNodePtr node, int options ATTRIBUTE_UNUSED)
{
xmlNsPtr *list = NULL;
int sizeList, nbList, i, j;
int sizeList = 0, nbList = 0, i, j;
xmlNsPtr ns;
if ((node == NULL) || (doc == NULL) || (node->doc != doc))