summaryrefslogtreecommitdiff
path: root/src/win32_memory.cpp
diff options
context:
space:
mode:
authorcyberbotx <cyberbotx@5417fbe8-f217-4b02-8779-1006273d7864>2009-07-19 07:24:57 +0000
committercyberbotx <cyberbotx@5417fbe8-f217-4b02-8779-1006273d7864>2009-07-19 07:24:57 +0000
commitcbec05c4286b042fa3cd586e132925bbac1a3a7d (patch)
treea0246b01b01e79c4c7dd43d566ce5de60327fd97 /src/win32_memory.cpp
parent906580a463acbbce328183979f92eb7088b7b20a (diff)
Fix for potentially undefined behavior in the Windows build, make the overloaded delete and delete[] operators check if the pointer is NULL before trying to use HeapFree(), thanks to Adam for pointing this out.
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2385 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/win32_memory.cpp')
-rw-r--r--src/win32_memory.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/win32_memory.cpp b/src/win32_memory.cpp
index 9da1b7812..cf78a531a 100644
--- a/src/win32_memory.cpp
+++ b/src/win32_memory.cpp
@@ -42,7 +42,8 @@ void * ::operator new(size_t iSize)
void ::operator delete(void *ptr)
{
- HeapFree(GetProcessHeap(), 0, ptr);
+ if (ptr)
+ HeapFree(GetProcessHeap(), 0, ptr);
}
void * operator new[](size_t iSize) {
@@ -55,7 +56,8 @@ void * operator new[](size_t iSize) {
void operator delete[](void *ptr)
{
- HeapFree(GetProcessHeap(), 0, ptr);
+ if (ptr)
+ HeapFree(GetProcessHeap(), 0, ptr);
}
#endif