From 21b0d00649240849dc6883908b1a1349ebe8c140 Mon Sep 17 00:00:00 2001 From: Dwayne Boone Date: Fri, 12 Jan 2007 15:11:11 +0000 Subject: Fixed match --- cpp/src/IceUtil/StringUtil.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'cpp/src/IceUtil/StringUtil.cpp') diff --git a/cpp/src/IceUtil/StringUtil.cpp b/cpp/src/IceUtil/StringUtil.cpp index d48d17001b8..12ce3e3cd1e 100644 --- a/cpp/src/IceUtil/StringUtil.cpp +++ b/cpp/src/IceUtil/StringUtil.cpp @@ -359,7 +359,7 @@ IceUtil::match(const string& s, const string& pat, bool emptyMatch) // // Make sure start of the strings match // - if(s.substr(0, beginIndex) != pat.substr(0, beginIndex)) + if(beginIndex > s.length() || s.substr(0, beginIndex) != pat.substr(0, beginIndex)) { return false; } @@ -368,7 +368,12 @@ IceUtil::match(const string& s, const string& pat, bool emptyMatch) // Make sure there is something present in the middle to match the // wildcard. If emptyMatch is true, allow a match of "". // - string::size_type endIndex = s.length() - (pat.length() - beginIndex - 1); + string::size_type endLength = pat.length() - beginIndex - 1; + if(endLength > s.length()) + { + return false; + } + string::size_type endIndex = s.length() - endLength; if(endIndex < beginIndex || (!emptyMatch && endIndex == beginIndex)) { return false; -- cgit v1.2.3