Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash double free of expr. #5557

Merged
merged 2 commits into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/parser/parser.yy
Original file line number Diff line number Diff line change
Expand Up @@ -1801,12 +1801,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 |