]> granicus.if.org Git - libexpat/commitdiff
Restore groupSize if (re)allocation of groupConnector fails
authorRhodri James <rhodri@kynesim.co.uk>
Tue, 7 Mar 2017 15:28:58 +0000 (15:28 +0000)
committerSebastian Pipping <sebastian@pipping.org>
Sun, 16 Jul 2017 21:02:30 +0000 (23:02 +0200)
expat/lib/xmlparse.c

index fd08b4ecdd1c45d5b95ea9252e7fe1b39258ee07..ba1fd9ae7c3e9c00c558328c528e859f66f6d84a 100644 (file)
@@ -4832,8 +4832,10 @@ doProlog(XML_Parser parser,
       if (prologState.level >= groupSize) {
         if (groupSize) {
           char *temp = (char *)REALLOC(groupConnector, groupSize *= 2);
-          if (temp == NULL)
+          if (temp == NULL) {
+            groupSize /= 2;
             return XML_ERROR_NO_MEMORY;
+          }
           groupConnector = temp;
           if (dtd->scaffIndex) {
             int *temp = (int *)REALLOC(dtd->scaffIndex,
@@ -4845,8 +4847,10 @@ doProlog(XML_Parser parser,
         }
         else {
           groupConnector = (char *)MALLOC(groupSize = 32);
-          if (!groupConnector)
+          if (!groupConnector) {
+            groupSize = 0;
             return XML_ERROR_NO_MEMORY;
+          }
         }
       }
       groupConnector[prologState.level] = 0;