From b6ee614a81d1759b3f8e570388d5c59f72d0a967 Mon Sep 17 00:00:00 2001 From: Oleg Prokhorov Date: Fri, 24 Oct 2003 00:29:43 +0000 Subject: [PATCH] Another portion of HeapReAlloc fixes. --- dlls/setupapi/parser.c | 11 +++++++++-- dlls/setupapi/virtcopy.c | 13 +++++++++++-- dlls/x11drv/xrender.c | 33 +++++++++++++++++++++++++++++---- 3 files changed, 49 insertions(+), 8 deletions(-) diff --git a/dlls/setupapi/parser.c b/dlls/setupapi/parser.c index f82924550a4..9369f21011e 100644 --- a/dlls/setupapi/parser.c +++ b/dlls/setupapi/parser.c @@ -159,10 +159,17 @@ static void *grow_array( void *array, unsigned int *count, size_t elem ) void *new_array; unsigned int new_count = *count + *count / 2; if (new_count < 32) new_count = 32; - if ((new_array = HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, array, new_count * elem ))) + + if (array) + new_array = HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, array, new_count * elem ); + else + new_array = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, new_count * elem ); + + if (new_array) *count = new_count; else - HeapFree( GetProcessHeap(), 0, array ); + if (array) + HeapFree( GetProcessHeap(), 0, array ); return new_array; } diff --git a/dlls/setupapi/virtcopy.c b/dlls/setupapi/virtcopy.c index 2f6562285f0..47c79dcf54a 100644 --- a/dlls/setupapi/virtcopy.c +++ b/dlls/setupapi/virtcopy.c @@ -124,7 +124,12 @@ VHSTR WINAPI vsmStringAdd16(LPCSTR lpszName) { index = vhstr_alloc; vhstr_alloc += 20; - vhstrlist = HeapReAlloc(heap, HEAP_ZERO_MEMORY, vhstrlist, + + if (vhstrlist) + vhstrlist = HeapReAlloc(heap, HEAP_ZERO_MEMORY, vhstrlist, + sizeof(VHSTR_STRUCT *) * vhstr_alloc); + else + vhstrlist = HeapAlloc(heap, HEAP_ZERO_MEMORY, sizeof(VHSTR_STRUCT *) * vhstr_alloc); } if (index == 0xffff) @@ -229,7 +234,11 @@ RETERR16 VCP_VirtnodeCreate(LPVCPFILESPEC vfsSrc, LPVCPFILESPEC vfsDst, WORD fl, if (vn_last == vn_num) { vn_num += 20; - pvnlist = HeapReAlloc(heap, HEAP_ZERO_MEMORY, pvnlist, + if (pvnlist) + pvnlist = HeapReAlloc(heap, HEAP_ZERO_MEMORY, pvnlist, + sizeof(LPVIRTNODE *) * vn_num); + else + pvnlist = HeapAlloc(heap, HEAP_ZERO_MEMORY, sizeof(LPVIRTNODE *) * vn_num); } pvnlist[vn_last] = HeapAlloc(heap, HEAP_ZERO_MEMORY, sizeof(VIRTNODE)); diff --git a/dlls/x11drv/xrender.c b/dlls/x11drv/xrender.c index 2082f8ec84a..efc90ac15ed 100644 --- a/dlls/x11drv/xrender.c +++ b/dlls/x11drv/xrender.c @@ -334,10 +334,17 @@ static int AllocEntry(void) } TRACE("Growing cache\n"); - glyphsetCache = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, + + if (glyphsetCache) + glyphsetCache = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, glyphsetCache, (glyphsetCacheSize + INIT_CACHE_SIZE) * sizeof(*glyphsetCache)); + else + glyphsetCache = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, + (glyphsetCacheSize + INIT_CACHE_SIZE) + * sizeof(*glyphsetCache)); + for(best = i = glyphsetCacheSize; i < glyphsetCacheSize + INIT_CACHE_SIZE; i++) { glyphsetCache[i].next = i + 1; @@ -538,19 +545,37 @@ static BOOL UploadGlyph(X11DRV_PDEVICE *physDev, int glyph) if(entry->nrealized <= glyph) { entry->nrealized = (glyph / 128 + 1) * 128; - entry->realized = HeapReAlloc(GetProcessHeap(), + + if (entry->realized) + entry->realized = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, entry->realized, entry->nrealized * sizeof(BOOL)); + else + entry->realized = HeapAlloc(GetProcessHeap(), + HEAP_ZERO_MEMORY, + entry->nrealized * sizeof(BOOL)); + if(entry->glyphset == 0) { - entry->bitmaps = HeapReAlloc(GetProcessHeap(), + if (entry->bitmaps) + entry->bitmaps = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, entry->bitmaps, entry->nrealized * sizeof(entry->bitmaps[0])); - entry->gis = HeapReAlloc(GetProcessHeap(), + else + entry->bitmaps = HeapAlloc(GetProcessHeap(), + HEAP_ZERO_MEMORY, + entry->nrealized * sizeof(entry->bitmaps[0])); + + if (entry->gis) + entry->gis = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, entry->gis, entry->nrealized * sizeof(entry->gis[0])); + else + entry->gis = HeapAlloc(GetProcessHeap(), + HEAP_ZERO_MEMORY, + entry->nrealized * sizeof(entry->gis[0])); } }