[libxml2] Fix some potential problems on reallocation failures(parser.c)



commit 5825ebb26a336d57cf31d0f9534829b74a2f852e
Author: Xia Xinfeng <xiaxf cn fujitsu com>
Date:   Thu Nov 10 13:50:22 2011 +0800

    Fix some potential problems on reallocation failures(parser.c)
    
    This problem is the same as d7958b21e7f8c447a26bb2436f08402b2c308be4.
    The operation "ctxt->nameMax * = 2;" should be placed after the function
    call of xmlRealloc().

 parser.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
---
diff --git a/parser.c b/parser.c
index 826284c..21d7aa3 100644
--- a/parser.c
+++ b/parser.c
@@ -1820,15 +1820,14 @@ namePush(xmlParserCtxtPtr ctxt, const xmlChar * value)
 
     if (ctxt->nameNr >= ctxt->nameMax) {
         const xmlChar * *tmp;
-        ctxt->nameMax *= 2;
         tmp = (const xmlChar * *) xmlRealloc((xmlChar * *)ctxt->nameTab,
-                                    ctxt->nameMax *
+                                    ctxt->nameMax * 2 *
                                     sizeof(ctxt->nameTab[0]));
         if (tmp == NULL) {
-	    ctxt->nameMax /= 2;
 	    goto mem_error;
         }
 	ctxt->nameTab = tmp;
+        ctxt->nameMax *= 2;
     }
     ctxt->nameTab[ctxt->nameNr] = value;
     ctxt->name = value;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]