rolled back to 2.9.1 because 2.9.2 doesn't work with connecting net
[platform/upstream/libxml2.git] / xmlmemory.c
index a3dc737..25d9318 100644 (file)
@@ -313,7 +313,7 @@ xmlMemMalloc(size_t size)
 void *
 xmlReallocLoc(void *ptr,size_t size, const char * file, int line)
 {
-    MEMHDR *p, *tmp;
+    MEMHDR *p;
     unsigned long number;
 #ifdef DEBUG_MEMORY
     size_t oldsize;
@@ -344,12 +344,10 @@ xmlReallocLoc(void *ptr,size_t size, const char * file, int line)
 #endif
     xmlMutexUnlock(xmlMemMutex);
 
-    tmp = (MEMHDR *) realloc(p,RESERVE_SIZE+size);
-    if (!tmp) {
-        free(p);
+    p = (MEMHDR *) realloc(p,RESERVE_SIZE+size);
+    if (!p) {
         goto error;
     }
-    p = tmp;
     if (xmlMemTraceBlockAt == ptr) {
        xmlGenericError(xmlGenericErrorContext,
                        "%p : Realloced(%lu -> %lu) Ok\n",
@@ -514,7 +512,10 @@ xmlMemStrdupLoc(const char *str, const char *file, int line)
 
     if (xmlMemStopAtBlock == p->mh_number) xmlMallocBreakpoint();
 
-    strcpy(s,str);
+    if (s != NULL)
+      strcpy(s,str);
+    else
+      goto error;
 
     TEST_POINT
 
@@ -582,15 +583,13 @@ xmlMemBlocks(void) {
 static void
 xmlMemContentShow(FILE *fp, MEMHDR *p)
 {
-    int i,j,k,len;
-    const char *buf;
+    int i,j,k,len = p->mh_size;
+    const char *buf = (const char *) HDR_2_CLIENT(p);
 
     if (p == NULL) {
        fprintf(fp, " NULL");
        return;
     }
-    len = p->mh_size;
-    buf = (const char *) HDR_2_CLIENT(p);
 
     for (i = 0;i < len;i++) {
         if (buf[i] == 0) break;