From 8f931c854038dada37b96db32a0b68ffe52981fa Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Wed, 24 Aug 2011 20:03:10 -0400 Subject: Fixed a crasher in cppunittest in sw, sd and sc on Windows. Be careful there... when bRemoved is true, the iterator would get incremented twice which may cause it to go past the end position. --- svtools/source/graphic/grfcache.cxx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'svtools') diff --git a/svtools/source/graphic/grfcache.cxx b/svtools/source/graphic/grfcache.cxx index 55d406389135..66bb2f74b044 100644 --- a/svtools/source/graphic/grfcache.cxx +++ b/svtools/source/graphic/grfcache.cxx @@ -693,12 +693,9 @@ void GraphicCache::ReleaseGraphicObject( const GraphicObject& rObj ) { // Release cached object bool bRemoved = false; - - for( - GraphicCacheEntryList::iterator it = maGraphicCache.begin(); - !bRemoved && it != maGraphicCache.end(); - ++it - ) { + GraphicCacheEntryList::iterator it = maGraphicCache.begin(); + while (!bRemoved && it != maGraphicCache.end()) + { bRemoved = (*it)->ReleaseGraphicObjectReference( rObj ); if( bRemoved ) @@ -727,6 +724,8 @@ void GraphicCache::ReleaseGraphicObject( const GraphicObject& rObj ) it = maGraphicCache.erase( it ); } } + else + ++it; } DBG_ASSERT( bRemoved, "GraphicCache::ReleaseGraphicObject(...): GraphicObject not found in cache" ); -- cgit