This is an automated email from the ASF dual-hosted git repository.
dataroaring pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.0 by this push:
new 7ad218553df branch-3.0: [fix](ubsan) fix ubsan error in
DataTypeHLL::serialize #50628 (#50668)
7ad218553df is described below
commit 7ad218553df117ba1da2c28a4ca54aed4a8e9b4b
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Wed May 14 21:00:22 2025 +0800
branch-3.0: [fix](ubsan) fix ubsan error in DataTypeHLL::serialize #50628
(#50668)
Cherry-picked from #50628
Co-authored-by: Mryange <[email protected]>
---
be/src/vec/data_types/data_type_hll.cpp | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/be/src/vec/data_types/data_type_hll.cpp
b/be/src/vec/data_types/data_type_hll.cpp
index 92f442fcb57..2e383705221 100644
--- a/be/src/vec/data_types/data_type_hll.cpp
+++ b/be/src/vec/data_types/data_type_hll.cpp
@@ -40,6 +40,14 @@ char* DataTypeHLL::serialize(const IColumn& column, char*
buf, int be_exec_versi
const auto* hll_column = &column;
size_t real_need_copy_num = 0;
buf = serialize_const_flag_and_row_num(&hll_column, buf,
&real_need_copy_num);
+ // In the code below, if the real_need_copy_num is 0, an empty vector
will be created. A vector with size 0 may return nullptr from data()
+ // https://en.cppreference.com/w/cpp/container/vector/data
+ // `If size() is 0, data() may or may not return a null pointer.`
+ // This would trigger a ubsan error: `null pointer passed as argument
2, which is declared to never be null`
+ // Other data types don't have this issue because they use Doris
internal pod array that guarantees data won't be nullptr.
+ if (real_need_copy_num == 0) {
+ return buf;
+ }
const auto& data_column = assert_cast<const ColumnHLL&>(*hll_column);
std::vector<size_t> hll_size_array(real_need_copy_num);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]