From c3034fce329017036c807e01261729bfc11a5d62 Mon Sep 17 00:00:00 2001 From: Lucian Grijincu Date: Mon, 9 Aug 2021 16:04:26 -0700 Subject: [PATCH] rocksdb: don't call LZ4_loadDictHC with null dictionary Summary: UBSAN revealed a pointer underflow when `LZ4HC_init_internal` is called with a null `start`. Reviewed By: ajkr Differential Revision: D30181874 fbshipit-source-id: ca9bbac1a85c58782871d7f153af733b000cc66c --- util/compression.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/util/compression.h b/util/compression.h index 5ce419c9c..207f9949e 100644 --- a/util/compression.h +++ b/util/compression.h @@ -1224,8 +1224,10 @@ inline bool LZ4HC_Compress(const CompressionInfo& info, const char* compression_dict_data = compression_dict.size() > 0 ? compression_dict.data() : nullptr; size_t compression_dict_size = compression_dict.size(); - LZ4_loadDictHC(stream, compression_dict_data, - static_cast(compression_dict_size)); + if (compression_dict_data != nullptr) { + LZ4_loadDictHC(stream, compression_dict_data, + static_cast(compression_dict_size)); + } #if LZ4_VERSION_NUMBER >= 10700 // r129+ outlen =