diff options
Diffstat (limited to 'xmlmemory.c')
-rw-r--r-- | xmlmemory.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/xmlmemory.c b/xmlmemory.c index a3dc737..25d9318 100644 --- a/xmlmemory.c +++ b/xmlmemory.c @@ -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; |