]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/str_map.cc: do boundry checks before access
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Fri, 13 Apr 2018 13:50:07 +0000 (15:50 +0200)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Fri, 13 Apr 2018 22:15:58 +0000 (00:15 +0200)
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
src/common/str_map.cc

index c3f6a2b6519e3c5b2597fd0ed7082de8c044d67e..6e952ab8419d0ec07da0a09880d7f78c81af7105 100644 (file)
@@ -59,10 +59,10 @@ int get_json_str_map(
 string trim(const string& str) {
   size_t start = 0;
   size_t end = str.size() - 1;
-  while (isspace(str[start]) != 0 && start <= end) {
+  while (start <= end && isspace(str[start]) != 0) {
     ++start;
   }
-  while (isspace(str[end]) != 0 && start <= end) {
+  while (start <= end && isspace(str[end]) != 0) {
     --end;
   }
   if (start <= end) {