fix crash in OptimizedRegularExpression

This commit is contained in:
chertus 2019-08-23 21:40:42 +03:00
parent baf121c864
commit a21b43913f
3 changed files with 5 additions and 2 deletions

View File

@ -1,4 +1,5 @@
#include <Common/Exception.h> #include <Common/Exception.h>
#include <Common/PODArray.h>
#include <Common/OptimizedRegularExpression.h> #include <Common/OptimizedRegularExpression.h>
#define MIN_LENGTH_FOR_STRSTR 3 #define MIN_LENGTH_FOR_STRSTR 3
@ -413,9 +414,9 @@ unsigned OptimizedRegularExpressionImpl<thread_safe>::match(const char * subject
return 0; return 0;
} }
StringPieceType pieces[MAX_SUBPATTERNS]; DB::PODArrayWithStackMemory<StringPieceType, sizeof(StringPieceType) * (MAX_SUBPATTERNS+1)> pieces(limit);
if (!re2->Match(StringPieceType(subject, subject_size), 0, subject_size, RegexType::UNANCHORED, pieces, limit)) if (!re2->Match(StringPieceType(subject, subject_size), 0, subject_size, RegexType::UNANCHORED, pieces.data(), pieces.size()))
return 0; return 0;
else else
{ {

View File

@ -0,0 +1 @@
['9']

View File

@ -0,0 +1 @@
SELECT extractAll('Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.143 YaBrowser/19.7.2.455 Yowser/2.5 Safari/537.36', '[Y][a-zA-Z]{8}/[1-9]([1-9]+)?(((.?)([0-9]+)?){0,4})?');