mirror of
https://github.com/postgres/postgres.git
synced 2025-07-07 00:36:50 +03:00
Fix nested NOT operation cleanup in tsquery.
During normalization of tsquery tree it tries to simplify nested NOT operations but there it's obvioulsy missed that subsequent node could be a leaf node (value node) Bug #14245: Segfault on weird to_tsquery Reported by David Kellum.
This commit is contained in:
@ -406,6 +406,8 @@ normalize_phrase_tree(NODE *node)
|
||||
|
||||
if (node->valnode->qoperator.oper == OP_NOT)
|
||||
{
|
||||
NODE *orignode = node;
|
||||
|
||||
/* eliminate NOT sequence */
|
||||
while (node->valnode->type == QI_OPR &&
|
||||
node->valnode->qoperator.oper == node->right->valnode->qoperator.oper)
|
||||
@ -413,7 +415,11 @@ normalize_phrase_tree(NODE *node)
|
||||
node = node->right->right;
|
||||
}
|
||||
|
||||
node->right = normalize_phrase_tree(node->right);
|
||||
if (orignode != node)
|
||||
/* current node isn't checked yet */
|
||||
node = normalize_phrase_tree(node);
|
||||
else
|
||||
node->right = normalize_phrase_tree(node->right);
|
||||
}
|
||||
else if (node->valnode->qoperator.oper == OP_PHRASE)
|
||||
{
|
||||
|
Reference in New Issue
Block a user