From 93b89d0e45db0b81943229aaf5517938291f4344 Mon Sep 17 00:00:00 2001 From: Qi Chen Date: Sat, 21 Sep 2024 08:48:06 +0800 Subject: [PATCH] [Fix](parquet-reader) Fix parquet reader crash in set_dict(). (#41074) ## Proposed changes Backport #40643 --- be/src/vec/exec/format/parquet/byte_array_dict_decoder.cpp | 3 +++ be/src/vec/exec/format/parquet/fix_length_dict_decoder.hpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/be/src/vec/exec/format/parquet/byte_array_dict_decoder.cpp b/be/src/vec/exec/format/parquet/byte_array_dict_decoder.cpp index 8b9532e68d0391..7c3d15b7c21d95 100644 --- a/be/src/vec/exec/format/parquet/byte_array_dict_decoder.cpp +++ b/be/src/vec/exec/format/parquet/byte_array_dict_decoder.cpp @@ -32,6 +32,9 @@ namespace doris::vectorized { Status ByteArrayDictDecoder::set_dict(std::unique_ptr& dict, int32_t length, size_t num_values) { _dict = std::move(dict); + if (_dict == nullptr) { + return Status::Corruption("Wrong dictionary data for byte array type, dict is null."); + } _dict_items.reserve(num_values); uint32_t offset_cursor = 0; char* dict_item_address = reinterpret_cast(_dict.get()); diff --git a/be/src/vec/exec/format/parquet/fix_length_dict_decoder.hpp b/be/src/vec/exec/format/parquet/fix_length_dict_decoder.hpp index 65e329ae89b5a4..3024405c2953fa 100644 --- a/be/src/vec/exec/format/parquet/fix_length_dict_decoder.hpp +++ b/be/src/vec/exec/format/parquet/fix_length_dict_decoder.hpp @@ -107,6 +107,9 @@ class FixLengthDictDecoder final : public BaseDictDecoder { return Status::Corruption("Wrong dictionary data for fixed length type"); } _dict = std::move(dict); + if (_dict == nullptr) { + return Status::Corruption("Wrong dictionary data for byte array type, dict is null."); + } char* dict_item_address = reinterpret_cast(_dict.get()); _dict_items.resize(num_values); _dict_value_to_code.reserve(num_values);