From 9c23fb8aca08b49aae6fc3a3ec710bf2686019ef Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Thu, 15 Mar 2012 22:02:44 +0100 Subject: Fixed fastRemoveOne when the element isn't found For a non-empty vectors that did not contain the element to remove, the loop would go on forever because a size_t can't become smaller than 0. Fixed by simply iterating forwards. --- src/scripting/script.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/scripting/script.cpp') diff --git a/src/scripting/script.cpp b/src/scripting/script.cpp index 074546ef..3e299461 100644 --- a/src/scripting/script.cpp +++ b/src/scripting/script.cpp @@ -141,7 +141,7 @@ void Script::loadNPC(const std::string &name, template static void fastRemoveOne(std::vector &vector, T value) { - for (size_t i = vector.size() - 1; i >= 0; --i) + for (size_t i = 0, size = vector.size(); i < size; ++i) { if (vector.at(i) == value) { -- cgit v1.2.3-70-g09d2