diff options
author | Patrick Georgi <pgeorgi@chromium.org> | 2017-01-02 19:24:48 +0100 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2017-01-03 22:17:04 +0100 |
commit | d05712529045e1694a834d57b0346c0b92a8735a (patch) | |
tree | 6d44dfdc2a90f5bb924aac80b1570931379a2c05 /util/romcc | |
parent | d8051896fd92c1250499a21c9cda0b4c834b8c68 (diff) | |
download | coreboot-d05712529045e1694a834d57b0346c0b92a8735a.tar.xz |
util/romcc: avoid leaking a type
Only allocate ptr_type when it's actually used.
Change-Id: Iea5f93601a42f02a1866bdff099f63935fdd5b8d
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Found-by: Coverity Scan #1129117
Reviewed-on: https://review.coreboot.org/18017
Tested-by: build bot (Jenkins)
Reviewed-by: Martin Roth <martinroth@google.com>
Diffstat (limited to 'util/romcc')
-rw-r--r-- | util/romcc/romcc.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/util/romcc/romcc.c b/util/romcc/romcc.c index 62fe758ef6..c2f5deed6c 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)); |