From 3b5953ff1d3dc56ce6ce80e7ca6234bf6130e3dd Mon Sep 17 00:00:00 2001 From: Francisco Santos Date: Fri, 14 Nov 2014 16:25:38 +0000 Subject: [PATCH] Realloc failure not handled Change-Id: If6e8e5989a131748aa4489d94e53d9da3a9db0fd --- dali/internal/common/message-buffer.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dali/internal/common/message-buffer.cpp b/dali/internal/common/message-buffer.cpp index 384347e..ae861b6 100644 --- a/dali/internal/common/message-buffer.cpp +++ b/dali/internal/common/message-buffer.cpp @@ -127,7 +127,17 @@ void MessageBuffer::IncreaseCapacity( std::size_t newCapacity ) if ( mData ) { // Often this avoids the need to copy memory + + unsigned int* oldData = mData; mData = reinterpret_cast( realloc( mData, newCapacity * sizeof(unsigned int) ) ); + + // if realloc fails the old data is still valid + if( !mData ) + { + // TODO: Process message queue to free up some data? + free(oldData); + DALI_ASSERT_DEBUG( false && "Realloc failed we're out of memory!" ); + } } else { -- 2.7.4