Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion be/src/util/simd/vstring_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <unistd.h>

#include <array>
#include <cstddef>
#include <cstdint>

#ifdef __aarch64__
Expand Down Expand Up @@ -144,7 +145,15 @@ class VStringFunctions {
} else {
for (size_t i = 0, char_size = 0; i < str.len; i += char_size) {
char_size = UTF8_BYTE_LENGTH[(unsigned char)(str.ptr)[i]];
std::copy(str.ptr + i, str.ptr + i + char_size, dst.ptr + str.len - i - char_size);
// there exists occasion where the last character is an illegal UTF-8 one which returns
// a char_size larger than the actual space, which would cause offset execeeding the buffer range
// for example, consider str.len=4, i = 3, then the last char returns char_size 2, then
// the str.ptr + offset would exceed the buffer range
size_t offset = i + char_size;
if (offset > str.len) {
offset = str.len;
}
std::copy(str.ptr + i, str.ptr + offset, dst.ptr + str.len - offset);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
fsnnygnaw
kn@8jlnuy

-- !select --
4

Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@

suite("test_reverse") {
qt_select "select reverse(k7) from test_query_db.test order by k1"
qt_select "select length( cast(reverse( cast(unhex( cast(hex( cast(651603156 as bigint)) as varchar)) as varchar)) as varchar)) as c3"
}