util/romcc: Add null check for filename

It is possible that 'filename' is still null in this if statement,
so we add an extra check to prevent a null dereference in strcmp.

Change-Id: Iaba95b63a4d552051e0c56445522de7274dfd0b3
Signed-off-by: Jacob Garber <jgarber1@ualberta.ca>
Found-by: Coverity CID 1395330
Reviewed-on: https://review.coreboot.org/c/coreboot/+/32922
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
This commit is contained in:
Jacob Garber 2019-05-21 18:55:34 -06:00 committed by Patrick Georgi
parent b4222a65ad
commit 4b688ab3fe
1 changed files with 1 additions and 1 deletions

View File

@ -1989,7 +1989,7 @@ static struct occurrence *new_occurrence(struct compile_state *state)
(last->line == line) &&
(last->function == function) &&
((last->filename == filename) ||
(strcmp(last->filename, filename) == 0)))
(filename != NULL && strcmp(last->filename, filename) == 0)))
{
get_occurrence(last);
return last;