[v3 PATCH] Make sure the return value of malloc_allocator::allocate is zero-initialized so that checking it for non-zero works later.

Ville Voutilainen ville.voutilainen@gmail.com
Sat Oct 15 19:44:00 GMT 2016


2016-10-15  Ville Voutilainen  <ville.voutilainen@gmail.com>

    Make sure the return value of malloc_allocator::allocate
    is zero-initialized so that checking it for non-zero works
    later.
    * include/ext/malloc_allocator.h (malloc_allocator::allocate):
    Initialize the return value.
-------------- next part --------------
diff --git a/libstdc++-v3/include/ext/malloc_allocator.h b/libstdc++-v3/include/ext/malloc_allocator.h
index acb60a2..113c1dc 100644
--- a/libstdc++-v3/include/ext/malloc_allocator.h
+++ b/libstdc++-v3/include/ext/malloc_allocator.h
@@ -101,7 +101,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	if (__n > this->max_size())
 	  std::__throw_bad_alloc();
 
-	pointer __ret;
+	pointer __ret = 0;
 #if __cpp_aligned_new
 #if __cplusplus > 201402L && _GLIBCXX_HAVE_ALIGNED_ALLOC
 	if (alignof(_Tp) > alignof(std::max_align_t))


More information about the Libstdc++ mailing list