mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
fixed runaway memory alloc bug on 64-bit in ParseString found by sirius-m
git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@74 1a98c847-1fd6-4fd8-948a-caf3550aa51b
This commit is contained in:
parent
d7d80a74d5
commit
2cffa7ce31
14
util.cpp
14
util.cpp
@ -282,15 +282,21 @@ bool error(const char* format, ...)
|
|||||||
|
|
||||||
void ParseString(const string& str, char c, vector<string>& v)
|
void ParseString(const string& str, char c, vector<string>& v)
|
||||||
{
|
{
|
||||||
unsigned int i1 = 0;
|
if (str.empty())
|
||||||
unsigned int i2;
|
return;
|
||||||
do
|
string::size_type i1 = 0;
|
||||||
|
string::size_type i2;
|
||||||
|
loop
|
||||||
{
|
{
|
||||||
i2 = str.find(c, i1);
|
i2 = str.find(c, i1);
|
||||||
|
if (i2 == str.npos)
|
||||||
|
{
|
||||||
|
v.push_back(str.substr(i1));
|
||||||
|
return;
|
||||||
|
}
|
||||||
v.push_back(str.substr(i1, i2-i1));
|
v.push_back(str.substr(i1, i2-i1));
|
||||||
i1 = i2+1;
|
i1 = i2+1;
|
||||||
}
|
}
|
||||||
while (i2 != str.npos);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user