components/stdcxx/patches/085-memory.cpp.patch
author Vladimir Marek <Vladimir.Marek@oracle.com>
Tue, 04 Oct 2016 14:04:16 +0200
changeset 7129 6587d6b48782
parent 402 94ae4d75524c
permissions -rw-r--r--
24794975 Update DBD::mysql to 4.0.37 24794982 problem in PERL-MOD/DBD-MYSQL

--- stdcxx-4.2.1/src/memory.cpp	2008-04-24 17:25:19.000000000 -0700
+++ stdcxx-4.2.1/src/memory.cpp	2011-03-19 14:22:20.379428656 -0700
@@ -29,22 +29,23 @@
 
 #define _RWSTD_LIB_SRC
 
+#include <rw/_defs.h>
 #include <rw/_error.h>
 #include <rw/_mutex.h>
 
 #include <new>
 #include <stdlib.h>
-
-#include <rw/_defs.h>
-
+#include <string.h>
 
 _RWSTD_NAMESPACE (__rw) {
 
-
 _RWSTD_EXPORT void*
 __rw_allocate (_RWSTD_SIZE_T nbytes, int /* = 0 */)
 {
-    void *ptr = 0;
+    void *ptr = 0UL;
+
+    if (0 == nbytes)
+	return ptr;
 
     _TRY {
 
@@ -65,12 +66,14 @@
     }
     _CATCH (...) {
         // prevent bad_alloc raised by the compiler
+	ptr = 0UL;
     }
 
     // fix broken ::operator new ()
-    if (0 == ptr)
+    if (0UL == ptr)
         _RW::__rw_throw (_RWSTD_ERROR_FIRST + 3 /* == bad_alloc */);
 
+    (void) memset (ptr, '\0', nbytes);
     return ptr;
 }