[coreboot-gerrit] New patch to review for coreboot: util/romcc: avoid leaking a type
Patrick Georgi (pgeorgi@google.com)
gerrit at coreboot.org
Mon Jan 2 19:26:16 CET 2017
Patrick Georgi (pgeorgi at google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/18017
-gerrit
commit d564d7fd7869ffd53ccc6d07377c825c956922e9
Author: Patrick Georgi <pgeorgi at chromium.org>
Date: Mon Jan 2 19:24:48 2017 +0100
util/romcc: avoid leaking a type
Only allocate ptr_type when it's actually used.
Change-Id: Iea5f93601a42f02a1866bdff099f63935fdd5b8d
Signed-off-by: Patrick Georgi <pgeorgi at chromium.org>
Found-by: Coverity Scan #1129117
---
util/romcc/romcc.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/util/romcc/romcc.c b/util/romcc/romcc.c
index 3574ca0..3cc72a7 100644
--- a/util/romcc/romcc.c
+++ b/util/romcc/romcc.c
@@ -7266,22 +7266,25 @@ static struct triple *do_mk_addr_expr(struct compile_state *state,
struct triple *expr, struct type *type, ulong_t offset)
{
struct triple *result;
- struct type *ptr_type;
clvalue(state, expr);
- ptr_type = new_type(TYPE_POINTER | (type->type & QUAL_MASK), type, 0);
-
result = 0;
if (expr->op == OP_ADECL) {
error(state, expr, "address of auto variables not supported");
}
else if (expr->op == OP_SDECL) {
+ struct type *ptr_type;
+ ptr_type = new_type(TYPE_POINTER | (type->type & QUAL_MASK), type, 0);
+
result = triple(state, OP_ADDRCONST, ptr_type, 0, 0);
MISC(result, 0) = expr;
result->u.cval = offset;
}
else if (expr->op == OP_DEREF) {
+ struct type *ptr_type;
+ ptr_type = new_type(TYPE_POINTER | (type->type & QUAL_MASK), type, 0);
+
result = triple(state, OP_ADD, ptr_type,
RHS(expr, 0),
int_const(state, &ulong_type, offset));
More information about the coreboot-gerrit
mailing list