util/romcc: Don't read 'member' if it might be NULL

The earlier loop exits gracefully iff i == index. In other cases, member
might be NULL, so check that the scan was successful before using its
results.

Change-Id: I818c233d797d82fa819243c4626dd9c4b7de3ac6
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Found-by: Coverity Scan #1129147
Reviewed-on: https://review.coreboot.org/17887
Tested-by: build bot (Jenkins)
Reviewed-by: Martin Roth <martinroth@google.com>
This commit is contained in:
Patrick Georgi 2016-12-15 15:24:06 +01:00 committed by Patrick Georgi
parent 305035cf27
commit adcad7f046
1 changed files with 1 additions and 2 deletions

View File

@ -6406,11 +6406,10 @@ static size_t index_reg_offset(struct compile_state *state,
i++;
member = member->right;
}
size += reg_needed_padding(state, member, size);
if (i != index) {
internal_error(state, 0, "Missing member index: %u", index);
}
size += reg_needed_padding(state, member, size);
}
else if ((type->type & TYPE_MASK) == TYPE_JOIN) {
ulong_t i;