Sanitize input in DB::MultiGet() API (#6054)

Summary:
The new DB::MultiGet() doesn't validate input for num_keys > 1 and GCC-9 complains about it. Fix it by directly return when num_keys == 0
Pull Request resolved: https://github.com/facebook/rocksdb/pull/6054

Test Plan: Build with GCC-9 and see it passes.

Differential Revision: D18608958

fbshipit-source-id: 1c279aff3c7fe6e9d5a6d085ed02550ecea4fdb2
This commit is contained in:
sdong 2019-11-20 10:35:56 -08:00 committed by Facebook Github Bot
parent 0306e01233
commit 27ec3b3466

View file

@ -1881,6 +1881,9 @@ void DBImpl::MultiGet(const ReadOptions& read_options, const size_t num_keys,
ColumnFamilyHandle** column_families, const Slice* keys, ColumnFamilyHandle** column_families, const Slice* keys,
PinnableSlice* values, Status* statuses, PinnableSlice* values, Status* statuses,
const bool sorted_input) { const bool sorted_input) {
if (num_keys == 0) {
return;
}
autovector<KeyContext, MultiGetContext::MAX_BATCH_SIZE> key_context; autovector<KeyContext, MultiGetContext::MAX_BATCH_SIZE> key_context;
autovector<KeyContext*, MultiGetContext::MAX_BATCH_SIZE> sorted_keys; autovector<KeyContext*, MultiGetContext::MAX_BATCH_SIZE> sorted_keys;
sorted_keys.resize(num_keys); sorted_keys.resize(num_keys);