From 4c37e7a3106b709aa89485156b5d6cec77aa3843 Mon Sep 17 00:00:00 2001 From: ishmal Date: Sat, 8 Mar 2008 20:41:09 +0000 Subject: [PATCH] Fixed bug found by JonCruz. Using an unsigned int in findLast() caused an infinite loop. --- src/dom/uri.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/dom/uri.cpp b/src/dom/uri.cpp index db45a2abf..562a674bb 100644 --- a/src/dom/uri.cpp +++ b/src/dom/uri.cpp @@ -10,7 +10,7 @@ * Authors: * Bob Jamison * - * Copyright (C) 2005-2007 Bob Jamison + * Copyright (C) 2005-2008 Bob Jamison * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -329,10 +329,11 @@ static int find(const std::vector &str, int ch, int startpos) static int findLast(const std::vector &str, int ch) { - // TODO FIXME BUGBUG - // This loop appears to be infinite, so it is probably not being called. - // Test for a problem, then fix after it has been observed locking up. - for (unsigned int i = str.size()-1 ; i>=0 ; i--) + /** + * Fixed. Originally I used an unsigned int for str.size(), + * which was dumb, since i>=0 would always be true. + */ + for (int i = ((int)str.size())-1 ; i>=0 ; i--) { if (ch == str[i]) return i; -- 2.30.2