From beb9633efd1e3b8d855a954b7ddc695e8e4bb443 Mon Sep 17 00:00:00 2001 From: Kimmo Hoikka Date: Wed, 23 Jul 2014 14:29:03 +0100 Subject: [PATCH] Fix regression in debug build & test cases [Problem] index going out of bounds [Cause] using wrong method [Solution] correct algorithm Change-Id: I2cd31458534fa8886b7ff27e711fe65e161a1b50 --- dali/public-api/signals/base-signal.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/dali/public-api/signals/base-signal.cpp b/dali/public-api/signals/base-signal.cpp index cb21f43..71ff408 100644 --- a/dali/public-api/signals/base-signal.cpp +++ b/dali/public-api/signals/base-signal.cpp @@ -289,18 +289,21 @@ void BaseSignal::CleanupConnections() // only do something if there are items if( total > 0 ) { - std::size_t removed = 0; + std::size_t index = 0; + // process the whole vector for( std::size_t i = 0; i < total; ++i ) { - if( mSignalConnections[ i ] == NULL ) + if( mSignalConnections[ index ] == NULL ) { - ++removed; - // swaps it to the end - mSignalConnections.Remove( mSignalConnections.Begin() + i ); + // items will be moved so don't increase index (erase will decrease the count of vector) + mSignalConnections.Erase( mSignalConnections.Begin() + index ); + } + else + { + // increase to next element + ++index; } } - // dont reallocate memory, just resize vector - mSignalConnections.Resize( total - removed ); } } -- 2.7.4