From: Devin Heitmueller Date: Fri, 20 Apr 2007 14:49:08 +0000 (-0700) Subject: [perl #42648] [PATCH] crash in win32/VMem.h when out of memory X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9e6e12112c10f1809160cb40af4fdf30fb0d160c;p=p5sagit%2Fp5-mst-13.2.git [perl #42648] [PATCH] crash in win32/VMem.h when out of memory From: "Devin Heitmueller" (via RT) Message-ID: p4raw-id: //depot/perl@31054 --- diff --git a/win32/vmem.h b/win32/vmem.h index 25f2376..460f557 100644 --- a/win32/vmem.h +++ b/win32/vmem.h @@ -164,6 +164,10 @@ void* VMem::Malloc(size_t size) #ifdef _USE_LINKED_LIST GetLock(); PMEMORY_BLOCK_HEADER ptr = (PMEMORY_BLOCK_HEADER)m_pmalloc(size+sizeof(MEMORY_BLOCK_HEADER)); + if (!ptr) { + FreeLock(); + return NULL; + } LinkBlock(ptr); FreeLock(); return (ptr+1); @@ -187,6 +191,10 @@ void* VMem::Realloc(void* pMem, size_t size) PMEMORY_BLOCK_HEADER ptr = (PMEMORY_BLOCK_HEADER)(((char*)pMem)-sizeof(MEMORY_BLOCK_HEADER)); UnlinkBlock(ptr); ptr = (PMEMORY_BLOCK_HEADER)m_prealloc(ptr, size+sizeof(MEMORY_BLOCK_HEADER)); + if (!ptr) { + FreeLock(); + return NULL; + } LinkBlock(ptr); FreeLock();