summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorPatrick Georgi <pgeorgi@chromium.org>2016-12-15 15:24:06 +0100
committerPatrick Georgi <pgeorgi@google.com>2016-12-16 18:45:56 +0100
commitadcad7f046aadaa88c5abb9bcc99bdacf1ff8639 (patch)
tree0131c8c478dd8fbcaa2c3f46feaac61033c29781 /util
parent305035cf2747529fadc894e5bef9e5c933baa2c0 (diff)
downloadcoreboot-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.c3
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;