Merge pull request #27181 from vdimir/issue-27169

Fix uninitialized memory in functions multiSearch* with empty array
This commit is contained in:
alexey-milovidov 2021-08-06 21:10:22 +03:00 committed by GitHub
commit e1927118cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 38 additions and 1 deletions

View File

@ -42,6 +42,8 @@ struct MultiSearchFirstIndexImpl
}
++iteration;
}
if (iteration == 0)
std::fill(res.begin(), res.end(), 0);
}
};

View File

@ -51,6 +51,8 @@ struct MultiSearchFirstPositionImpl
}
++iteration;
}
if (iteration == 0)
std::fill(res.begin(), res.end(), 0);
}
};

View File

@ -41,6 +41,8 @@ struct MultiSearchImpl
}
++iteration;
}
if (iteration == 0)
std::fill(res.begin(), res.end(), 0);
}
};

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;