Skip to content

Commit

Permalink
Fix crash double free of expr. (vesoft-inc#5557) (vesoft-inc#2785)
Browse files Browse the repository at this point in the history
* Fix crash double free of expr.

* Change issue id.

Co-authored-by: shylock <33566796+Shylock-Hg@users.noreply.github.com>
  • Loading branch information
Sophie-Xie and Shylock-Hg authored May 22, 2023
1 parent 2f0a7e3 commit 558eb01
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/parser/parser.yy
Original file line number Diff line number Diff line change
Expand Up @@ -1830,12 +1830,10 @@ match_node
$$ = new MatchNode();
}
| parenthesized_expression {
auto& e = $1;
if (e->kind() != Expression::Kind::kLabel) {
delete $1;
if ($1->kind() != Expression::Kind::kLabel) {
throw nebula::GraphParser::syntax_error(@1, "Invalid node pattern");
}
$$ = new MatchNode(static_cast<LabelExpression*>(e)->name(), nullptr, nullptr);
$$ = new MatchNode(static_cast<LabelExpression*>($1)->name(), nullptr, nullptr);
}
| L_PAREN match_alias match_node_label_list R_PAREN {
$$ = new MatchNode(*$2, $3, nullptr);
Expand Down
32 changes: 32 additions & 0 deletions tests/tck/features/bugfix/SyntaxErrorCrash.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright (c) 2023 vesoft inc. All rights reserved.
#
# This source code is licensed under Apache 2.0 License.
# #5558
Feature: Test crash double delete expr

Background:
Given a graph with space named "nba"

Scenario: crash double delete expr
When executing query:
"""
match (v.player) return v;
"""
Then a SyntaxError should be raised at runtime: Invalid node pattern near `(v.player)'
When executing query:
"""
match (v.player) return v;
"""
Then a SyntaxError should be raised at runtime: Invalid node pattern near `(v.player)'
When executing query:
"""
match (v.player) return v;
"""
Then a SyntaxError should be raised at runtime: Invalid node pattern near `(v.player)'
When executing query:
"""
return 1;
"""
Then the result should be, in any order:
| 1 |
| 1 |

0 comments on commit 558eb01

Please sign in to comment.