summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoranonymous <local@localhost>2011-01-20 00:12:33 +0600
committeranonymous <local@localhost>2011-01-20 00:12:33 +0600
commit168b9dc6cfcd21ff3e1c568ec10ec92b5fbb8801 (patch)
treece71d12e46a65562733323a400778c3dc83ee24f
parente30d71b58877d9a29d47100312bb71d86a608ab6 (diff)
downloadlibcxxrt-168b9dc6cfcd21ff3e1c568ec10ec92b5fbb8801.tar.gz
libcxxrt-168b9dc6cfcd21ff3e1c568ec10ec92b5fbb8801.tar.bz2
libcxxrt-168b9dc6cfcd21ff3e1c568ec10ec92b5fbb8801.tar.xz
fix for COMPILER-8945: nothrow operator new should return NULL if new handler throws std::bad_alloc
-rw-r--r--src/memory.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/memory.cc b/src/memory.cc
index 16167ff..7e0fc3c 100644
--- a/src/memory.cc
+++ b/src/memory.cc
@@ -51,7 +51,14 @@ void * operator new(size_t size, const std::nothrow_t &) throw() {
void * mem = malloc(size);
while(mem == NULL) {
if(new_handl != NULL) {
- new_handl();
+ try {
+ new_handl();
+ }
+ catch(std::bad_alloc &) {
+ // nothrow operator new should return NULL in case of
+ // std::bad_alloc exception in new handler
+ return NULL;
+ }
} else {
return NULL;
}