summaryrefslogtreecommitdiff
path: root/xpath.c
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@redhat.com>2010-11-15 12:06:29 +0100
committerDaniel Veillard <veillard@redhat.com>2010-11-15 12:10:14 +0100
commit0cbeb50ee03ce582a0c979c70d8fbf030e270c37 (patch)
treebeae3f6c78c9922fbf1698216b7a7be3aee51d72 /xpath.c
parent364e3d2b054656f2cf97594365d15b2ddb72a9ed (diff)
downloadlibxml2-0cbeb50ee03ce582a0c979c70d8fbf030e270c37.tar.gz
Fix a potential memory access error
in case of a previus allocation error
Diffstat (limited to 'xpath.c')
-rw-r--r--xpath.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/xpath.c b/xpath.c
index 4d6826d7..81e33f65 100644
--- a/xpath.c
+++ b/xpath.c
@@ -3575,13 +3575,13 @@ xmlXPathNodeSetAdd(xmlNodeSetPtr cur, xmlNodePtr val) {
} else if (cur->nodeNr == cur->nodeMax) {
xmlNodePtr *temp;
- cur->nodeMax *= 2;
- temp = (xmlNodePtr *) xmlRealloc(cur->nodeTab, cur->nodeMax *
+ temp = (xmlNodePtr *) xmlRealloc(cur->nodeTab, cur->nodeMax * 2 *
sizeof(xmlNodePtr));
if (temp == NULL) {
xmlXPathErrMemory(NULL, "growing nodeset\n");
return;
}
+ cur->nodeMax *= 2;
cur->nodeTab = temp;
}
if (val->type == XML_NAMESPACE_DECL) {