From 82d0b002e203ea1e8deb2f39ee6145155afde96f Mon Sep 17 00:00:00 2001 From: Guillaume Melquiond Date: Sun, 21 Oct 2007 17:03:50 +0000 Subject: Fixed double-free of sprite actions. --- ChangeLog | 1 + src/resources/action.cpp | 11 +++-------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9bcf2a63..599086a4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21,6 +21,7 @@ * src/gui/quitdialog.cpp: Plugged memory leak in quit dialog. * src/resources/iteminfo.cpp, src/resources/iteminfo.h: Plugged memory leak in equipment sound. + * src/resources/action.cpp: Fixed double-free of sprite actions. 2007-10-20 Guillaume Melquiond diff --git a/src/resources/action.cpp b/src/resources/action.cpp index 247455db..6b3c2f52 100644 --- a/src/resources/action.cpp +++ b/src/resources/action.cpp @@ -45,10 +45,11 @@ Action::getAnimation(int direction) const { Animations::const_iterator i = mAnimations.find(direction); - // When the direction isn't defined, try the default + // When the given direction is not available, return the first one. + // (either DEFAULT, or more usually DOWN). if (i == mAnimations.end()) { - i = mAnimations.find(0); + i = mAnimations.begin(); } return (i == mAnimations.end()) ? NULL : i->second; @@ -57,11 +58,5 @@ Action::getAnimation(int direction) const void Action::setAnimation(int direction, Animation *animation) { - // Set first direction as default direction - if (mAnimations.empty()) - { - mAnimations[0] = animation; - } - mAnimations[direction] = animation; } -- cgit v1.2.3-70-g09d2