From 67501cfc9aabd32c626c1c7a6f4f8b53a92d70dd Mon Sep 17 00:00:00 2001 From: Islam AbdelRahman Date: Fri, 7 Oct 2016 17:16:13 -0700 Subject: [PATCH] Fix -ve std::string::resize 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 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/util/cf_options.cc b/util/cf_options.cc index 25399a88d..a57670ec7 100644 --- a/util/cf_options.cc +++ b/util/cf_options.cc @@ -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);