diff options
author | Patrick Georgi <pgeorgi@chromium.org> | 2016-12-15 15:24:06 +0100 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2016-12-16 18:45:56 +0100 |
commit | adcad7f046aadaa88c5abb9bcc99bdacf1ff8639 (patch) | |
tree | 0131c8c478dd8fbcaa2c3f46feaac61033c29781 /util | |
parent | 305035cf2747529fadc894e5bef9e5c933baa2c0 (diff) | |
download | coreboot-adcad7f046aadaa88c5abb9bcc99bdacf1ff8639.tar.xz |
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>
Diffstat (limited to 'util')
-rw-r--r-- | util/romcc/romcc.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/util/romcc/romcc.c b/util/romcc/romcc.c index 7b5e5d7e12..baf8014f0a 100644 --- a/util/romcc/romcc.c +++ b/util/romcc/romcc.c @@ -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; |