summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorDwayne Boone <dwayne@zeroc.com>2007-01-12 15:11:11 +0000
committerDwayne Boone <dwayne@zeroc.com>2007-01-12 15:11:11 +0000
commit21b0d00649240849dc6883908b1a1349ebe8c140 (patch)
tree66f2781b9c9b0296cef7ab4a43e5928e9d3545a2 /cpp/src
parentFixed compile error (diff)
downloadice-21b0d00649240849dc6883908b1a1349ebe8c140.tar.bz2
ice-21b0d00649240849dc6883908b1a1349ebe8c140.tar.xz
ice-21b0d00649240849dc6883908b1a1349ebe8c140.zip
Fixed match
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/IceUtil/StringUtil.cpp9
1 files changed, 7 insertions, 2 deletions
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;