diff options
author | Robert Pösel <robyer@seznam.cz> | 2014-04-14 12:13:09 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2014-04-14 12:13:09 +0000 |
commit | 73af3297ebf6253ce4bad65545391941a7c0f179 (patch) | |
tree | b583dfb401698ceaa4e5a878989ef851b865a04a /protocols | |
parent | 5a3503225b9f0b864e901067867e481905f8f2d9 (diff) |
Facebook: fix crash when using trim() on empty string
git-svn-id: http://svn.miranda-ng.org/main/trunk@8972 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/FacebookRM/src/utils.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/protocols/FacebookRM/src/utils.cpp b/protocols/FacebookRM/src/utils.cpp index 5e8a44ed05..ce46bdbfe6 100644 --- a/protocols/FacebookRM/src/utils.cpp +++ b/protocols/FacebookRM/src/utils.cpp @@ -334,11 +334,14 @@ std::string utils::text::slashu_to_utf8(std::string data) std::string utils::text::trim(std::string data, bool rtrim)
{
+ if (data.empty())
+ return "";
+
std::string spaces = " \t\r\n"; // TODO: include "nbsp"?
std::string::size_type begin = rtrim ? 0 : data.find_first_not_of(spaces);
std::string::size_type end = data.find_last_not_of(spaces) + 1;
- return (end != std::string::npos) ? data.substr(begin, end - begin) : "";
+ return (begin != std::string::npos && end != std::string::npos) ? data.substr(begin, end - begin) : "";
}
void utils::text::explode(std::string str, std::string separator, std::vector<std::string>* results)
|