mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-16 19:32:07 +00:00
fix crash and clean code
This commit is contained in:
parent
787bf0eb8e
commit
65831dcbc9
@ -243,7 +243,7 @@ struct ReplaceRegexpImpl
|
|||||||
|
|
||||||
for (size_t i = 0; i < input_rows_count; ++i)
|
for (size_t i = 0; i < input_rows_count; ++i)
|
||||||
{
|
{
|
||||||
size_t from = i > 0 ? haystack_offsets[i - 1] : 0;
|
size_t from = haystack_offsets[i - 1];
|
||||||
|
|
||||||
const char * hs_data = reinterpret_cast<const char *>(haystack_data.data() + from);
|
const char * hs_data = reinterpret_cast<const char *>(haystack_data.data() + from);
|
||||||
const size_t hs_length = static_cast<unsigned>(haystack_offsets[i] - from - 1);
|
const size_t hs_length = static_cast<unsigned>(haystack_offsets[i] - from - 1);
|
||||||
@ -274,19 +274,19 @@ struct ReplaceRegexpImpl
|
|||||||
|
|
||||||
for (size_t i = 0; i < input_rows_count; ++i)
|
for (size_t i = 0; i < input_rows_count; ++i)
|
||||||
{
|
{
|
||||||
size_t hs_from = i > 0 ? haystack_offsets[i - 1] : 0;
|
size_t hs_from = haystack_offsets[i - 1];
|
||||||
const char * hs_data = reinterpret_cast<const char *>(haystack_data.data() + hs_from);
|
const char * hs_data = reinterpret_cast<const char *>(haystack_data.data() + hs_from);
|
||||||
const size_t hs_length = static_cast<unsigned>(haystack_offsets[i] - hs_from - 1);
|
const size_t hs_length = static_cast<unsigned>(haystack_offsets[i] - hs_from - 1);
|
||||||
|
|
||||||
size_t ndl_from = i > 0 ? needle_offsets[i - 1] : 0;
|
size_t ndl_from = needle_offsets[i - 1];
|
||||||
const char * ndl_data = reinterpret_cast<const char *>(needle_data.data() + ndl_from);
|
const char * ndl_data = reinterpret_cast<const char *>(needle_data.data() + ndl_from);
|
||||||
const size_t ndl_length = static_cast<unsigned>(needle_offsets[i] - ndl_from - 1);
|
const size_t ndl_length = static_cast<unsigned>(needle_offsets[i] - ndl_from - 1);
|
||||||
std::string_view needle(ndl_data, ndl_length);
|
std::string_view needle(ndl_data, ndl_length);
|
||||||
|
|
||||||
if (needle.empty())
|
if (needle.empty())
|
||||||
{
|
{
|
||||||
memcpySmallAllowReadWriteOverflow15(&res_data[i > 0 ? res_offsets[i - 1] : 0], hs_data, hs_length + 1);
|
res_data.insert(res_data.end(), hs_data, hs_data + hs_length);
|
||||||
res_offsets[i] = (i > 0 ? res_offsets[i - 1] : 0) + hs_length + 1;
|
res_offsets[i] = res_offsets[i - 1] + hs_length + 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,11 +336,11 @@ struct ReplaceRegexpImpl
|
|||||||
|
|
||||||
for (size_t i = 0; i < input_rows_count; ++i)
|
for (size_t i = 0; i < input_rows_count; ++i)
|
||||||
{
|
{
|
||||||
size_t hs_from = i > 0 ? haystack_offsets[i - 1] : 0;
|
size_t hs_from = haystack_offsets[i - 1];
|
||||||
const char * hs_data = reinterpret_cast<const char *>(haystack_data.data() + hs_from);
|
const char * hs_data = reinterpret_cast<const char *>(haystack_data.data() + hs_from);
|
||||||
const size_t hs_length = static_cast<unsigned>(haystack_offsets[i] - hs_from - 1);
|
const size_t hs_length = static_cast<unsigned>(haystack_offsets[i] - hs_from - 1);
|
||||||
|
|
||||||
size_t repl_from = i > 0 ? replacement_offsets[i - 1] : 0;
|
size_t repl_from = replacement_offsets[i - 1];
|
||||||
const char * repl_data = reinterpret_cast<const char *>(replacement_data.data() + repl_from);
|
const char * repl_data = reinterpret_cast<const char *>(replacement_data.data() + repl_from);
|
||||||
const size_t repl_length = static_cast<unsigned>(replacement_offsets[i] - repl_from - 1);
|
const size_t repl_length = static_cast<unsigned>(replacement_offsets[i] - repl_from - 1);
|
||||||
std::string_view replacement(repl_data, repl_length);
|
std::string_view replacement(repl_data, repl_length);
|
||||||
@ -375,23 +375,23 @@ struct ReplaceRegexpImpl
|
|||||||
|
|
||||||
for (size_t i = 0; i < input_rows_count; ++i)
|
for (size_t i = 0; i < input_rows_count; ++i)
|
||||||
{
|
{
|
||||||
size_t hs_from = i > 0 ? haystack_offsets[i - 1] : 0;
|
size_t hs_from = haystack_offsets[i - 1];
|
||||||
const char * hs_data = reinterpret_cast<const char *>(haystack_data.data() + hs_from);
|
const char * hs_data = reinterpret_cast<const char *>(haystack_data.data() + hs_from);
|
||||||
const size_t hs_length = static_cast<unsigned>(haystack_offsets[i] - hs_from - 1);
|
const size_t hs_length = static_cast<unsigned>(haystack_offsets[i] - hs_from - 1);
|
||||||
|
|
||||||
size_t ndl_from = i > 0 ? needle_offsets[i - 1] : 0;
|
size_t ndl_from = needle_offsets[i - 1];
|
||||||
const char * ndl_data = reinterpret_cast<const char *>(needle_data.data() + ndl_from);
|
const char * ndl_data = reinterpret_cast<const char *>(needle_data.data() + ndl_from);
|
||||||
const size_t ndl_length = static_cast<unsigned>(needle_offsets[i] - ndl_from - 1);
|
const size_t ndl_length = static_cast<unsigned>(needle_offsets[i] - ndl_from - 1);
|
||||||
std::string_view needle(ndl_data, ndl_length);
|
std::string_view needle(ndl_data, ndl_length);
|
||||||
|
|
||||||
if (needle.empty())
|
if (needle.empty())
|
||||||
{
|
{
|
||||||
memcpySmallAllowReadWriteOverflow15(&res_data[i > 0 ? res_offsets[i - 1] : 0], hs_data, hs_length + 1);
|
res_data.insert(res_data.end(), hs_data, hs_data + hs_length);
|
||||||
res_offsets[i] = (i > 0 ? res_offsets[i - 1] : 0) + hs_length + 1;
|
res_offsets[i] = res_offsets[i - 1] + hs_length + 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t repl_from = i > 0 ? replacement_offsets[i - 1] : 0;
|
size_t repl_from = replacement_offsets[i - 1];
|
||||||
const char * repl_data = reinterpret_cast<const char *>(replacement_data.data() + repl_from);
|
const char * repl_data = reinterpret_cast<const char *>(replacement_data.data() + repl_from);
|
||||||
const size_t repl_length = static_cast<unsigned>(replacement_offsets[i] - repl_from - 1);
|
const size_t repl_length = static_cast<unsigned>(replacement_offsets[i] - repl_from - 1);
|
||||||
std::string_view replacement(repl_data, repl_length);
|
std::string_view replacement(repl_data, repl_length);
|
||||||
|
Loading…
Reference in New Issue
Block a user