From b9ce156e381ad1f4d7baad0f285c3f429812ea4f Mon Sep 17 00:00:00 2001 From: Yueh-Hsuan Chiang Date: Tue, 25 Mar 2014 13:38:28 -0700 Subject: [PATCH] Add assert to MergeOperator::PartialMergeMulti to check # of operands. Summary: Add assert(operands_list.size() >= 2) in MergeOperator::PartialMergeMulti to ensure it's only be called when we have at least two merge operands. Test Plan: run merge_test and stringappend_test. Reviewers: haobo, igor Reviewed By: igor CC: leveldb Differential Revision: https://reviews.facebook.net/D17169 --- db/merge_operator.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/db/merge_operator.cc b/db/merge_operator.cc index d96b165a6..a01d389e9 100644 --- a/db/merge_operator.cc +++ b/db/merge_operator.cc @@ -18,6 +18,7 @@ bool MergeOperator::PartialMergeMulti(const Slice& key, const std::deque& operand_list, std::string* new_value, Logger* logger) const { + assert(operand_list.size() >= 2); // Simply loop through the operands std::string temp_value; Slice temp_slice(operand_list[0]);