Realloc failure not handled 40/30340/2
authorFrancisco Santos <f1.santos@samsung.com>
Fri, 14 Nov 2014 16:25:38 +0000 (16:25 +0000)
committerFrancisco Santos <f1.santos@samsung.com>
Mon, 17 Nov 2014 13:47:14 +0000 (05:47 -0800)
Change-Id: If6e8e5989a131748aa4489d94e53d9da3a9db0fd

dali/internal/common/message-buffer.cpp

index 384347e..ae861b6 100644 (file)
@@ -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<unsigned int*>( 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
   {