summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Garber <jgarber1@ualberta.ca>2019-05-21 14:42:24 -0600
committerPatrick Georgi <pgeorgi@google.com>2019-05-23 09:02:18 +0000
commit298afb3140fa8f092b356ec89d8be2f5a36b530f (patch)
tree6a8190e3f9d1f933bdd4abe0f45728826bffe325
parent9742ae1d11dab3357835fab7d7e3577dde4e0480 (diff)
downloadcoreboot-298afb3140fa8f092b356ec89d8be2f5a36b530f.tar.xz
util/romcc: Add extra null pointer check
It is possible that 'lnode->val' is set to 0 on a previous iteration of the loop, so check that it is non-null here before dereferencing it. Change-Id: I9827dd5623eaf11240df605a8b50ff9e27a5fce0 Signed-off-by: Jacob Garber <jgarber1@ualberta.ca> Found-by: Coverity CID 1129149 Reviewed-on: https://review.coreboot.org/c/coreboot/+/32917 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Patrick Georgi <pgeorgi@google.com>
-rw-r--r--util/romcc/romcc.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/util/romcc/romcc.c b/util/romcc/romcc.c
index d60a9a7f83..2a158e5fe0 100644
--- a/util/romcc/romcc.c
+++ b/util/romcc/romcc.c
@@ -20944,7 +20944,8 @@ static void scc_visit_phi(struct compile_state *state, struct scc_state *scc,
}
}
/* meet(const, const) = const or lattice low */
- else if (!constants_equal(state, lnode->val, tmp->val)) {
+ else if (lnode->val != 0 &&
+ !constants_equal(state, lnode->val, tmp->val)) {
lnode->val = 0;
}