Skip to content

Commit

Permalink
fix: prevent crash when using 'trap' keyword in specific contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
jacopodl committed Aug 2, 2024
1 parent e9e66b5 commit 9a31aa4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions argon/lang/parser2/parser2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2776,6 +2776,8 @@ Node *Parser::ParseTrap(Context *context) {
this->Eat(true);

auto *right = this->ParseExpression(context, PeekPrecedence(TokenType::COMMA));
if (right == nullptr)
throw ParserException(this->tkcur_.loc, kStandardError[0]);

// Expressions with multiple traps are useless,
// if the expression is already a trap, return it immediately
Expand Down Expand Up @@ -2917,10 +2919,10 @@ Module *Parser::Parse() {
// This exception can be safely ignored!
return nullptr;
} catch (const ParserException &e) {
ErrorFormat("ParserError", "%s - column: %d, line: %d: %s",
ErrorFormat("ParserError", "%s - line: %d, column: %d: %s",
this->filename_,
e.loc.start.column,
e.loc.start.line,
e.loc.start.column,
e.what());
return nullptr;
} catch (const ScannerException &) {
Expand Down

0 comments on commit 9a31aa4

Please sign in to comment.