From 9dc43fc43558420ae07c834caec943dc68434ca4 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Thu, 25 Jun 2020 19:57:30 +0300 Subject: [PATCH] Fix race condition in extractAllGroups --- src/Functions/MatchImpl.h | 4 ++-- src/Functions/extractAllGroups.h | 3 ++- src/Functions/extractGroups.cpp | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Functions/MatchImpl.h b/src/Functions/MatchImpl.h index 0b5de70cfa0..a851fe3dd58 100644 --- a/src/Functions/MatchImpl.h +++ b/src/Functions/MatchImpl.h @@ -126,7 +126,7 @@ struct MatchImpl { size_t size = offsets.size(); - const auto & regexp = Regexps::get(pattern); + auto regexp = Regexps::get(pattern); std::string required_substring; bool is_trivial; @@ -281,7 +281,7 @@ struct MatchImpl { size_t size = data.size() / n; - const auto & regexp = Regexps::get(pattern); + auto regexp = Regexps::get(pattern); std::string required_substring; bool is_trivial; diff --git a/src/Functions/extractAllGroups.h b/src/Functions/extractAllGroups.h index 8216a528b2c..8d42b5a810d 100644 --- a/src/Functions/extractAllGroups.h +++ b/src/Functions/extractAllGroups.h @@ -82,7 +82,8 @@ public: throw Exception("Length of 'needle' argument must be greater than 0.", ErrorCodes::BAD_ARGUMENTS); using StringPiece = typename Regexps::Regexp::StringPieceType; - const auto & regexp = Regexps::get(needle)->getRE2(); + auto holder = Regexps::get(needle); + const auto & regexp = holder->getRE2(); if (!regexp) throw Exception("There are no groups in regexp: " + needle, ErrorCodes::BAD_ARGUMENTS); diff --git a/src/Functions/extractGroups.cpp b/src/Functions/extractGroups.cpp index f24abd2d0ff..252d165757b 100644 --- a/src/Functions/extractGroups.cpp +++ b/src/Functions/extractGroups.cpp @@ -61,7 +61,7 @@ public: if (needle.empty()) throw Exception(getName() + " length of 'needle' argument must be greater than 0.", ErrorCodes::BAD_ARGUMENTS); - const auto regexp = Regexps::get(needle); + auto regexp = Regexps::get(needle); const auto & re2 = regexp->getRE2(); if (!re2)