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>
This commit is contained in:
parent
d8051896fd
commit
d057125290
|
@ -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));
|
||||
|
|
Loading…
Reference in New Issue