aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schickel2010-03-10 20:33:38 +0000
committerJohannes Schickel2010-03-10 20:33:38 +0000
commit80fae481b0d97b8de64803275067fa08dbe1c720 (patch)
treeef8a35070bc8ca76ebc18734bb59d93f0b9456c4
parent91e7d2746883b622648d6542d34345e1a18fb943 (diff)
downloadscummvm-rg350-80fae481b0d97b8de64803275067fa08dbe1c720.tar.gz
scummvm-rg350-80fae481b0d97b8de64803275067fa08dbe1c720.tar.bz2
scummvm-rg350-80fae481b0d97b8de64803275067fa08dbe1c720.zip
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. svn-id: r48225
-rw-r--r--engines/saga/events.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/engines/saga/events.cpp b/engines/saga/events.cpp
index 98f206b29d..0ed1f2b3d9 100644
--- a/engines/saga/events.cpp
+++ b/engines/saga/events.cpp
@@ -288,9 +288,10 @@ int Events::handleOneShot(Event *event) {
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;
}