From 48a95c0f26593605cd4502b99139fb0cdb9a3552 Mon Sep 17 00:00:00 2001 From: Vlad Khorsun Date: Mon, 22 Aug 2022 21:38:35 +0300 Subject: [PATCH] Fixed bug #7276 : Firebird 4 literal containing crashes server --- src/jrd/optimizer/Optimizer.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/jrd/optimizer/Optimizer.cpp b/src/jrd/optimizer/Optimizer.cpp index d34cc4aa9a..f6f82ef033 100644 --- a/src/jrd/optimizer/Optimizer.cpp +++ b/src/jrd/optimizer/Optimizer.cpp @@ -3000,10 +3000,12 @@ BoolExprNode* Optimizer::makeInferenceNode(BoolExprNode* boolean, // Share impure area for cached invariant value used to hold pre-compiled // pattern for new LIKE and CONTAINING algorithms. + // Cached pattern matcher also should be shared by both nodes, else new node + // could overwrite impure area at offset zero. See bug GH-7276. // Proper cloning of impure area for this node would require careful accounting // of new invariant dependencies - we avoid such hassles via using single // cached pattern value for all node clones. This is faster too. - if (newCmpNode->nodFlags & ExprNode::FLAG_INVARIANT) + if (newCmpNode->nodFlags & (ExprNode::FLAG_INVARIANT | ExprNode::FLAG_PATTERN_MATCHER_CACHE)) newCmpNode->impureOffset = cmpNode->impureOffset; // But substitute new values for some of the predicate arguments