summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authorDevin Heitmueller <devin.heitmueller@gmail.com>2007-04-20 07:49:08 -0700
committerSteve Hay <SteveHay@planit.com>2007-04-24 12:16:07 +0000
commit9e6e12112c10f1809160cb40af4fdf30fb0d160c (patch)
tree6579db3a4bdd7056e9f4088b6a686464408990c8 /win32
parent13d771f075428106b872fe78aa3d944467de9082 (diff)
downloadperl-9e6e12112c10f1809160cb40af4fdf30fb0d160c.tar.gz
[perl #42648] [PATCH] crash in win32/VMem.h when out of memory
From: "Devin Heitmueller" (via RT) <perlbug-followup@perl.org> Message-ID: <rt-3.6.HEAD-30201-1177105747-239.42648-75-0@perl.org> p4raw-id: //depot/perl@31054
Diffstat (limited to 'win32')
-rw-r--r--win32/vmem.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/win32/vmem.h b/win32/vmem.h
index 25f2376f0a..460f55793a 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();