From d8051896fd92c1250499a21c9cda0b4c834b8c68 Mon Sep 17 00:00:00 2001 From: Patrick Georgi Date: Mon, 2 Jan 2017 19:15:44 +0100 Subject: [PATCH] util/romcc: avoid dereferencing NULL pointer argv is only filled for macro->argc > 0. Change-Id: I5ff21098384afc823efa14be3d5565507fb2b3b2 Signed-off-by: Patrick Georgi Found-by: Coverity Scan #1287089 Reviewed-on: https://review.coreboot.org/18016 Tested-by: build bot (Jenkins) Reviewed-by: Martin Roth --- util/romcc/romcc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/util/romcc/romcc.c b/util/romcc/romcc.c index 2fa400af2b..62fe758ef6 100644 --- a/util/romcc/romcc.c +++ b/util/romcc/romcc.c @@ -4580,6 +4580,9 @@ static void expand_macro(struct compile_state *state, flen = fmacro.pos - fstart; switch(tk->tok) { case TOK_IDENT: + if (macro->argc < 0) { + break; + } for(i = 0; i < macro->argc; i++) { if (argv[i].ident == tk->ident) { break;