From eecd8fba460b4a4f1961bc696b210bb78308aa0b Mon Sep 17 00:00:00 2001 From: Peter Dillinger Date: Thu, 30 Apr 2020 12:08:34 -0700 Subject: [PATCH] Fix assertion that can fail on sst corruption (#6780) Summary: An assertion that a char == a CompressionType (unsigned char) originally cast from a char can fail if the original value is negative, due to numeric promotion. The assertion should pass even if the value is invalid CompressionType, because the callee UncompressBlockContentsForCompressionType checks for that and reports status appropriately. Pull Request resolved: https://github.com/facebook/rocksdb/pull/6780 Test Plan: Temporarily change kZSTD = 0x88 and see tests fail. Make this change (in addition), and tests pass. Reviewed By: siying Differential Revision: D21328498 Pulled By: pdillinger fbshipit-source-id: 61caf8d815581ce49261ecb7ab0f396e9ac4bb92 --- table/format.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/table/format.cc b/table/format.cc index 3bc964424..c84a59904 100644 --- a/table/format.cc +++ b/table/format.cc @@ -463,7 +463,7 @@ Status UncompressBlockContents(const UncompressionInfo& uncompression_info, const ImmutableCFOptions& ioptions, MemoryAllocator* allocator) { assert(data[n] != kNoCompression); - assert(data[n] == uncompression_info.type()); + assert(data[n] == static_cast(uncompression_info.type())); return UncompressBlockContentsForCompressionType(uncompression_info, data, n, contents, format_version, ioptions, allocator);