Fix uninitialized memory in functions multiSearch* with empty array

This commit is contained in:
vdimir 2021-08-04 16:44:39 +03:00
parent d9f55a3f31
commit b8558a1716
No known key found for this signature in database
GPG Key ID: F57B3E10A21DBB31
6 changed files with 36 additions and 5 deletions

View File

@ -109,7 +109,7 @@ public:
auto & vec_res = col_res->getData();
auto & offsets_res = col_offsets->getData();
vec_res.resize(column_haystack_size * refs.size());
vec_res.resize_fill(column_haystack_size * refs.size());
if (col_haystack_vector)
Impl::vectorConstant(col_haystack_vector->getChars(), col_haystack_vector->getOffsets(), refs, vec_res);

View File

@ -26,7 +26,7 @@ struct MultiSearchFirstIndexImpl
{
auto searcher = Impl::createMultiSearcherInBigHaystack(needles);
const size_t haystack_string_size = haystack_offsets.size();
res.resize(haystack_string_size);
res.resize_fill(haystack_string_size);
size_t iteration = 0;
while (searcher.hasMoreToSearch())
{

View File

@ -30,7 +30,7 @@ struct MultiSearchFirstPositionImpl
};
auto searcher = Impl::createMultiSearcherInBigHaystack(needles);
const size_t haystack_string_size = haystack_offsets.size();
res.resize(haystack_string_size);
res.resize_fill(haystack_string_size);
size_t iteration = 0;
while (searcher.hasMoreToSearch())
{

View File

@ -26,7 +26,7 @@ struct MultiSearchImpl
{
auto searcher = Impl::createMultiSearcherInBigHaystack(needles);
const size_t haystack_string_size = haystack_offsets.size();
res.resize(haystack_string_size);
res.resize_fill(haystack_string_size);
size_t iteration = 0;
while (searcher.hasMoreToSearch())
{

View File

@ -23796,3 +23796,19 @@
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

View File

@ -483,6 +483,22 @@ select 1 = position('abab', materialize('ab'));
select 1 = position('abababababababababababab', materialize('abab'));
select 1 = position('abababababababababababab', materialize('abababababababababa'));
select 0 = multiSearchAny('\0', CAST([], 'Array(String)'));
select 0 = multiSearchAnyCaseInsensitive('\0', CAST([], 'Array(String)'));
select 0 = multiSearchAnyCaseInsensitiveUTF8('\0', CAST([], 'Array(String)'));
select 0 = multiSearchAnyUTF8('\0', CAST([], 'Array(String)'));
select 0 = multiSearchFirstIndex('\0', CAST([], 'Array(String)'));
select 0 = multiSearchFirstIndexCaseInsensitive('\0', CAST([], 'Array(String)'));
select 0 = multiSearchFirstIndexCaseInsensitiveUTF8('\0', CAST([], 'Array(String)'));
select 0 = multiSearchFirstIndexUTF8('\0', CAST([], 'Array(String)'));
select 0 = multiSearchFirstPosition('\0', CAST([], 'Array(String)'));
select 0 = multiSearchFirstPositionCaseInsensitive('\0', CAST([], 'Array(String)'));
select 0 = multiSearchFirstPositionCaseInsensitiveUTF8('\0', CAST([], 'Array(String)'));
select 0 = multiSearchFirstPositionUTF8('\0', CAST([], 'Array(String)'));
select [] = multiSearchAllPositions('\0', CAST([], 'Array(String)'));
select [] = multiSearchAllPositionsCaseInsensitive('\0', CAST([], 'Array(String)'));
select [] = multiSearchAllPositionsCaseInsensitiveUTF8('\0', CAST([], 'Array(String)'));
select [] = multiSearchAllPositionsUTF8('\0', CAST([], 'Array(String)'));
select [2] = multiSearchAllPositions(materialize('abcdefgh'), ['b']);
select [2] = multiSearchAllPositions(materialize('abcdefgh'), ['bc']);
@ -1177,7 +1193,6 @@ select 0 = multiSearchAnyCaseInsensitiveUTF8(materialize('ШНвпкфЗвгДж
select 1 = multiSearchAnyCaseInsensitiveUTF8(materialize('ФРХгаСлчЧОцкШгзмКЗшФфББвЧ'), ['кзШфФб', 'ГАслЧЧОцкшг', 'ФфббВЧ', 'ЦкШ', '', 'АслчЧОЦКШгзМкЗШффбБвч', 'РХгаслЧчОЦКШГз', 'РхгаслчЧОцКШгзМкзшФфБбВ', 'Шг', 'Ф', 'ХГАслчЧоцКШГзМкзш', 'ШгЗмКЗшфФб']) from system.numbers limit 10;
select 1 = multiSearchAnyCaseInsensitiveUTF8(materialize('ЧдйШкхОлалщНйбССХКаФзОМрКЕЙР'), ['бссХкафзОм', 'ХОЛаЛщнйБссХкаФз', 'лаЛщнйБсСХ', 'ЩнЙбСсхКаФЗО', 'йБСсХКАФЗОмР', 'йшкХолаЛЩНйбсСхК', 'С', '', 'ЙшкхОлалщНЙБсСхКаФзом', 'Йр', 'щнЙБссхКАфзоМрК', 'рКе']) from system.numbers limit 10;
select 1 = multiSearchFirstIndex(materialize('alhpvldsiwsydwhfdasqju'), ['sydwh', 'dwh', 'dwhfdasqj', 'w', 'briozrtpq', 'fdasq', 'lnuvpuxdhhuxjbolw', 'vldsiws', 'dasqju', 'uancllygwoifwnnp', 'wfxputfnen', 'hzaclvjumecnmweungz']) from system.numbers limit 10;
select 0 = multiSearchFirstIndex(materialize('kcwchxxyujbhrxkxgnomg'), ['jmvqipszutxfnhdfaxqwoxcz', 'nrgzkbsakdtdiiyphozjoauyughyvlz', 'qbszx', 'sllthykcnttqecpequommemygee', 'bvsbdiufrrrjxaxzxgbd', 'hdkpcmpdyjildw', 'frxkyukiywngfcxfzwkcun', 'dmvxf', 'esamivybor', 'eoggdynqwlnlxr']) from system.numbers limit 10;
select 0 = multiSearchFirstIndex(materialize('zggbeilrfpkleafjjldgyfgn'), ['rpypxkpgvljhqthneremvabcd', 'qchzlnsctuwkdxqcrjgihvtfxhqxfqsxm', 'vtozkivjyqcqetmqenuihq', 'fixcvjyzbzejmwdivjf', 'lydoolvnuuamwlnzbyuuwpqqjaxf', 'elkodwthxqpcybwezm', 'wpiju', 'wdzuuwumlqfvga', 'iokphkai', 'wkbwdstplhivjyk', 'wxfbhfturuqoymwklohawgwltptytc', 'jehprkzofqvurepbvuwdqj']) from system.numbers limit 10;