From a9a973869afd987a6b728b833b2896dbb38bc02f Mon Sep 17 00:00:00 2001 From: Zhichao Cao Date: Thu, 9 Jul 2020 18:11:41 -0700 Subject: [PATCH] Fix status message size assert (#7045) Summary: In status.cc, the assert is `assert(sizeof(msgs) > index)`; msgs is a const char* array, sizeof(msgs) is the array size*char* size, which will make the assert pass all the time. Change it to sizeof(msgs)/sizeof(char*) > index. Pull Request resolved: https://github.com/facebook/rocksdb/pull/7045 Test Plan: pass make check Reviewed By: cheng-chang Differential Revision: D22291337 Pulled By: zhichao-cao fbshipit-source-id: 4ba8ebbb8da80ace7ca6adcdb0c66726f993659d --- util/status.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/status.cc b/util/status.cc index ace4f1411..c9fa2659b 100644 --- a/util/status.cc +++ b/util/status.cc @@ -134,7 +134,7 @@ std::string Status::ToString() const { std::string result(type); if (subcode_ != kNone) { uint32_t index = static_cast(subcode_); - assert(sizeof(msgs) > index); + assert(sizeof(msgs) / sizeof(msgs[0]) > index); result.append(msgs[index]); }