]> granicus.if.org Git - libexpat/commitdiff
Revert recorded size of attribute memory when reallocation fails
authorRhodri James <rhodri@kynesim.co.uk>
Fri, 17 Feb 2017 12:01:30 +0000 (12:01 +0000)
committerSebastian Pipping <sebastian@pipping.org>
Sun, 16 Jul 2017 16:56:23 +0000 (18:56 +0200)
expat/lib/xmlparse.c

index c430541f4cfbc17317debd16ce3c205bd3d6a5d4..00f4b7bdd3a9c8504c7b974feb3a62a67c80edc4 100644 (file)
@@ -3117,13 +3117,17 @@ storeAtts(XML_Parser parser, const ENCODING *enc,
 #endif
     attsSize = n + nDefaultAtts + INIT_ATTS_SIZE;
     temp = (ATTRIBUTE *)REALLOC((void *)atts, attsSize * sizeof(ATTRIBUTE));
-    if (temp == NULL)
+    if (temp == NULL) {
+      attsSize = oldAttsSize;
       return XML_ERROR_NO_MEMORY;
+    }
     atts = temp;
 #ifdef XML_ATTR_INFO
     temp2 = (XML_AttrInfo *)REALLOC((void *)attInfo, attsSize * sizeof(XML_AttrInfo));
-    if (temp2 == NULL)
+    if (temp2 == NULL) {
+      attsSize = oldAttsSize;
       return XML_ERROR_NO_MEMORY;
+    }
     attInfo = temp2;
 #endif
     if (n > oldAttsSize)