mirror of
https://github.com/anope/anope.git
synced 2026-06-26 10:16:40 +02:00
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
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user