]> granicus.if.org Git - gc/commitdiff
Check traceable_allocator.allocate result before dereference in test_cpp
authorIvan Maidanski <ivmai@mail.ru>
Wed, 24 Oct 2012 03:57:45 +0000 (07:57 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Wed, 24 Oct 2012 08:58:09 +0000 (12:58 +0400)
* tests/test_cpp.cc (main): Check "xptr" value (obtained from
traceable_allocator.allocate) for NULL (and exit with the
corresponding message in that case) before dereferencing it.

tests/test_cpp.cc

index ca42d2473a6c6bcbc961344781c6a0fd6b68448f..dd11b92791b03fe54f761c8d22f78cf55b4126a0 100644 (file)
@@ -228,6 +228,10 @@ int APIENTRY WinMain( HINSTANCE instance ATTR_UNUSED,
 #   endif
     *x = 29;
 #   ifndef DONT_USE_STD_ALLOCATOR
+      if (!xptr) {
+        fprintf(stderr, "Out of memory!\n");
+        exit(3);
+      }
       *xptr = x;
       x = 0;
 #   endif