[Scummvm-cvs-logs] SF.net SVN: scummvm:[48225] scummvm/trunk/engines/saga/events.cpp

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Wed Mar 10 21:33:38 CET 2010


Revision: 48225
          http://scummvm.svn.sourceforge.net/scummvm/?rev=48225&view=rev
Author:   lordhoto
Date:     2010-03-10 20:33:38 +0000 (Wed, 10 Mar 2010)

Log Message:
-----------
Fix a valgrind warning.

It is *not* a good idea to pass a reference to a list entry to List::remove.
Since List::remove will remove *all* occurances of that list entry, it will
also invaldiate the reference, resulting in invalid memory reads after the
entry has been removed from the list, when List::remove will continue to
search the rest of the list for more occurances of the same entry.

Modified Paths:
--------------
    scummvm/trunk/engines/saga/events.cpp

Modified: scummvm/trunk/engines/saga/events.cpp
===================================================================
--- scummvm/trunk/engines/saga/events.cpp	2010-03-10 17:05:25 UTC (rev 48224)
+++ scummvm/trunk/engines/saga/events.cpp	2010-03-10 20:33:38 UTC (rev 48225)
@@ -288,9 +288,10 @@
 		case kEventDisplay:
 			((TextListEntry *)event->data)->display = true;
 			break;
-		case kEventRemove:
-			_vm->_scene->_textList.remove(*((TextListEntry *)event->data));
-			break;
+		case kEventRemove: {
+			TextListEntry entry = *((TextListEntry *)event->data);
+			_vm->_scene->_textList.remove(entry);
+			} break;
 		default:
 			break;
 		}


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list