From 91e615bfecaa0958cb178176a52318edca3dfda5 Mon Sep 17 00:00:00 2001 From: s_nakamoto Date: Fri, 5 Mar 2010 01:13:27 +0000 Subject: [PATCH] fixed runaway memory alloc bug on 64-bit in ParseString found by sirius-m --- util.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/util.cpp b/util.cpp index 09de89b1..acfbcd6c 100644 --- a/util.cpp +++ b/util.cpp @@ -282,15 +282,21 @@ bool error(const char* format, ...) void ParseString(const string& str, char c, vector& 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); }