From 6e73cd6aa9805c592f8e572d6b9c774c561f11bd Mon Sep 17 00:00:00 2001 From: Ryan Goldberg Date: Thu, 19 Jan 2023 14:30:18 -0500 Subject: [PATCH] Added null-checks to parser --- parse.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/parse.cxx b/parse.cxx index 912ce65e5..3fe2d921d 100644 --- a/parse.cxx +++ b/parse.cxx @@ -2073,7 +2073,7 @@ parser::parse_synthetic_probe (const token* chain) input.set_current_file(0); input.set_current_token_chain(0); - p->synthetic = true; + if(p) p->synthetic = true; return p; } @@ -2521,6 +2521,8 @@ parser::do_parse_functiondecl (vector& functions, const token* t, } t = peek(); + if(!t) + throw PARSE_ERROR (_("expected '{'")); if (t->type == tok_operator && t->content == ":") { swallow(); @@ -2919,6 +2921,8 @@ parser::parse_return_statement () s->tok = t; t = peek (); + if(!t) + throw PARSE_ERROR (_("expected ';', '}' or an expression statement")); if (t->type == tok_operator && (t->content == ";" || t->content == "}")) s->value = NULL; // no return value else -- 2.43.5