diff options
author | s_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b> | 2010-03-05 01:13:27 +0000 |
---|---|---|
committer | s_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b> | 2010-03-05 01:13:27 +0000 |
commit | 91e615bfecaa0958cb178176a52318edca3dfda5 (patch) | |
tree | 0d2e3ba27e9e6a1de2b3fed9a2ae27ff63be0fb5 /util.cpp | |
parent | 9a3358220449e75966bb188f2dc49310107b676d (diff) |
fixed runaway memory alloc bug on 64-bit in ParseString found by sirius-m
Diffstat (limited to 'util.cpp')
-rw-r--r-- | util.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -282,15 +282,21 @@ bool error(const char* format, ...) void ParseString(const string& str, char c, vector<string>& v)
{
- unsigned int i1 = 0;
- unsigned int i2;
- do
+ if (str.empty())
+ return;
+ string::size_type i1 = 0;
+ string::size_type i2;
+ loop
{
i2 = str.find(c, i1);
+ if (i2 == str.npos)
+ {
+ v.push_back(str.substr(i1));
+ return;
+ }
v.push_back(str.substr(i1, i2-i1));
i1 = i2+1;
}
- while (i2 != str.npos);
}
|