From 9b6d50bfeffcd682b5bbb9fe23d47f613311fa1f Mon Sep 17 00:00:00 2001 From: Mryange <59914473+Mryange@users.noreply.github.com> Date: Wed, 12 Jun 2024 17:59:31 +0800 Subject: [PATCH] [ub](pod array) fix applying non-zero offset 16 to null pointer (#36086) ## Proposed changes ``` /root/doris/be/src/vec/common/pod_array.h:448:13: runtime error: applying non-zero offset 16 to null pointer #0 0x562f904159f3 in void doris::vectorized::PODArray, unsigned long, doris::vectorized::AggregateFunctionSequenceMatch, unsigned long> >::PatternAction, 64ul, AllocatorWithStackMemory, 64ul, 8ul>, 0ul, 0ul>::emplace_back, unsigned long, doris::vectorized::AggregateFunctionSequenceMatch, unsigned long> >::PatternActionType>(doris::vectorized::AggregateFunctionSequenceMatchData, unsigned long, doris::vectorized::AggregateFunctionSequenceMatch, unsigned long> >::PatternActionType&&) /root/doris/be/src/vec/common/pod_array.h:448:13 #1 0x562f90412d6a in doris::vectorized::AggregateFunctionSequenceMatchData, unsigned long, doris::vectorized::AggregateFunctionSequenceMatch, unsigned long> >::parse_pattern() /root/doris/be/src/vec/aggregate_functions/aggregate_function_sequence_match.h:208:17 #2 0x562f9040a824 in doris::vectorized::AggregateFunctionSequenceMatchData, unsigned long, doris::vectorized::AggregateFunctionSequenceMatch, unsigned long> >::init(std::__cxx11::basic_string, std::allocator >, unsigned long) /root/doris/be/src/vec/aggregate_functions/aggregate_function_sequence_match.h:95:13 ``` this->c_end may be nullptr --- be/src/vec/common/pod_array.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/be/src/vec/common/pod_array.h b/be/src/vec/common/pod_array.h index 9a00e295cb34fa..d4324c91f75e4f 100644 --- a/be/src/vec/common/pod_array.h +++ b/be/src/vec/common/pod_array.h @@ -445,7 +445,8 @@ class PODArray : public PODArrayBase void emplace_back(Args&&... args) { - if (UNLIKELY(this->c_end + sizeof(T) > this->c_end_of_storage)) { + if (UNLIKELY(this->c_end == nullptr || + (this->c_end + sizeof(T) > this->c_end_of_storage))) { this->reserve_for_next_size(); }