summaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
authorOleg Morozenkov <omorozenkov@gmail.com>2015-08-04 09:17:19 +0300
committerOleg Morozenkov <omorozenkov@gmail.com>2015-08-04 09:17:19 +0300
commitd92c8909d4dbfc3919c7353b74d2ff3a5ddfcee2 (patch)
tree13f79edf9b7483648befb881add16ca623171ea5 /src/tools
parent99072def67e54d664edd96b9c0f124c4f09cedee (diff)
Fix StringTools
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/StringTools.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/tools/StringTools.cpp b/src/tools/StringTools.cpp
index 188e71c..deb8fa1 100644
--- a/src/tools/StringTools.cpp
+++ b/src/tools/StringTools.cpp
@@ -31,7 +31,10 @@ using namespace std;
namespace StringTools {
bool startsWith(const string& str1, const string& str2) {
- string::const_iterator it1(str1.begin());
+ if (str1.length() < str2.length()) {
+ return false;
+ }
+ string::const_iterator it1(str1.begin());
string::const_iterator end1(str1.end());
string::const_iterator it2(str2.begin());
string::const_iterator end2(str2.end());
@@ -46,7 +49,10 @@ bool startsWith(const string& str1, const string& str2) {
}
bool endsWith(const string& str1, const string& str2) {
- string::const_iterator it1(str1.end());
+ if (str1.length() < str2.length()) {
+ return false;
+ }
+ string::const_iterator it1(str1.end());
string::const_iterator begin1(str1.begin());
string::const_iterator it2(str2.end());
string::const_iterator begin2(str2.begin());