From d35821abe7cb287cfe3bc8d083e5471db1708475 Mon Sep 17 00:00:00 2001 From: Ti Chi Robot Date: Thu, 14 Apr 2022 21:00:36 +0800 Subject: [PATCH] fix null case for GetJsonLength (#3734) (#3737) close pingcap/tiflash#2705 --- dbms/src/Storages/Transaction/JSONCodec.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dbms/src/Storages/Transaction/JSONCodec.cpp b/dbms/src/Storages/Transaction/JSONCodec.cpp index 5c7755f2b5c..24656657065 100644 --- a/dbms/src/Storages/Transaction/JSONCodec.cpp +++ b/dbms/src/Storages/Transaction/JSONCodec.cpp @@ -61,7 +61,6 @@ */ namespace DB { - namespace ErrorCodes { extern const int LOGICAL_ERROR; @@ -277,6 +276,10 @@ String DecodeJsonAsBinary(size_t & cursor, const String & raw_value) { return De UInt64 GetJsonLength(std::string_view raw_value) { + if (raw_value.empty()) + { + return 0; + } switch (raw_value[0]) // JSON Root element type { case TYPE_CODE_OBJECT: