From: Ryan Goldberg Date: Thu, 19 Jan 2023 19:30:18 +0000 (-0500) Subject: Added null-checks to parser X-Git-Tag: release-4.9a~36 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=6e73cd6aa9805c592f8e572d6b9c774c561f11bd;p=systemtap.git Added null-checks to parser --- 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