mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Fix UBSan report in substring
This commit is contained in:
parent
a04360e6b2
commit
ae8de8259f
@ -91,9 +91,11 @@ public:
|
||||
if (column_start_const)
|
||||
{
|
||||
if (start_value > 0)
|
||||
sliceFromLeftConstantOffsetUnbounded(source, StringSink(*col_res, input_rows_count), start_value - 1);
|
||||
sliceFromLeftConstantOffsetUnbounded(
|
||||
source, StringSink(*col_res, input_rows_count), static_cast<size_t>(start_value - 1));
|
||||
else if (start_value < 0)
|
||||
sliceFromRightConstantOffsetUnbounded(source, StringSink(*col_res, input_rows_count), -start_value);
|
||||
sliceFromRightConstantOffsetUnbounded(
|
||||
source, StringSink(*col_res, input_rows_count), -static_cast<size_t>(start_value));
|
||||
else
|
||||
throw Exception("Indices in strings are 1-based", ErrorCodes::ZERO_ARRAY_OR_TUPLE_INDEX);
|
||||
}
|
||||
@ -105,9 +107,11 @@ public:
|
||||
if (column_start_const && column_length_const)
|
||||
{
|
||||
if (start_value > 0)
|
||||
sliceFromLeftConstantOffsetBounded(source, StringSink(*col_res, input_rows_count), start_value - 1, length_value);
|
||||
sliceFromLeftConstantOffsetBounded(
|
||||
source, StringSink(*col_res, input_rows_count), static_cast<size_t>(start_value - 1), length_value);
|
||||
else if (start_value < 0)
|
||||
sliceFromRightConstantOffsetBounded(source, StringSink(*col_res, input_rows_count), -start_value, length_value);
|
||||
sliceFromRightConstantOffsetBounded(
|
||||
source, StringSink(*col_res, input_rows_count), -static_cast<size_t>(start_value), length_value);
|
||||
else
|
||||
throw Exception("Indices in strings are 1-based", ErrorCodes::ZERO_ARRAY_OR_TUPLE_INDEX);
|
||||
}
|
||||
|
@ -0,0 +1,7 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
1
tests/queries/0_stateless/01665_substring_ubsan.sql
Normal file
1
tests/queries/0_stateless/01665_substring_ubsan.sql
Normal file
@ -0,0 +1 @@
|
||||
SELECT substringUTF8(materialize(''), -9223372036854775808) FROM numbers(7);
|
Loading…
Reference in New Issue
Block a user