diff mbox

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

Message ID CAFk2RUb5+nFNqWquj9K4352XT8NAfsmEHEVF3ovh9nni8R2v-g@mail.gmail.com
State New
Headers show

Commit Message

Ville Voutilainen Oct. 15, 2016, 7:44 p.m. UTC
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.
diff mbox

Patch

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))