summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Chisnall <dchisnall@pathscale.com>2012-03-28 09:49:53 +0100
committerDavid Chisnall <dchisnall@pathscale.com>2012-03-28 09:49:53 +0100
commit02a01135a4d93c1e0029242f0889a59e6fe6beca (patch)
tree089eb924ac853cf09195fc944858c8ffe8f37aff
parentfb8cc3b07be8677604df8df8e7b270edc2000aef (diff)
downloadlibcxxrt-02a01135a4d93c1e0029242f0889a59e6fe6beca.tar.gz
libcxxrt-02a01135a4d93c1e0029242f0889a59e6fe6beca.tar.bz2
libcxxrt-02a01135a4d93c1e0029242f0889a59e6fe6beca.tar.xz
Correctly handle the case where 0 is passed to operator new.
-rw-r--r--src/memory.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/memory.cc b/src/memory.cc
index fec861a..cc879e0 100644
--- a/src/memory.cc
+++ b/src/memory.cc
@@ -74,6 +74,10 @@ namespace std
__attribute__((weak))
void* operator new(size_t size)
{
+ if (0 == size)
+ {
+ size = 1;
+ }
void * mem = malloc(size);
while (0 == mem)
{
@@ -95,6 +99,10 @@ void* operator new(size_t size)
__attribute__((weak))
void* operator new(size_t size, const std::nothrow_t &) throw()
{
+ if (0 == size)
+ {
+ size = 1;
+ }
void *mem = malloc(size);
while (0 == mem)
{