]> git-server-git.apps.pok.os.sepia.ceph.com Git - rocksdb.git/commitdiff
Fix -ve std::string::resize
authorIslam AbdelRahman <tec@fb.com>
Sat, 8 Oct 2016 00:16:13 +0000 (17:16 -0700)
committerIslam AbdelRahman <tec@fb.com>
Sat, 8 Oct 2016 00:16:13 +0000 (17:16 -0700)
Summary:
I saw this exception thrown because sometimes we may resize with -ve value
if we have empty max_bytes_for_level_multiplier_additional vector

Test Plan: run the tests

Reviewers: yiwu

Reviewed By: yiwu

Subscribers: andrewkr, dhruba

Differential Revision: https://reviews.facebook.net/D64791

util/cf_options.cc

index 25399a88df86a1243c129b71a2c5bcbc6bcff6d4..a57670ec752ee723df5c944585648c19cdd2e9c9 100644 (file)
@@ -153,7 +153,12 @@ void MutableCFOptions::Dump(Logger* log) const {
     snprintf(buf, sizeof(buf), "%d, ", m);
     result += buf;
   }
-  result.resize(result.size() - 2);
+  if (result.size() >= 2) {
+    result.resize(result.size() - 2);
+  } else {
+    result = "";
+  }
+
   Log(log, "max_bytes_for_level_multiplier_additional: %s", result.c_str());
   Log(log, "           verify_checksums_in_compaction: %d",
       verify_checksums_in_compaction);