diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-12-18 15:14:18 +0100 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-12-21 01:53:52 +0100 |
commit | fe71f6b3064072ba5a6b8531c76b531bbb3b963d (patch) | |
tree | 0b4872816d6f9e36cba18b768c6c1bd239ca584f /evaluate.c | |
parent | 9a0fe9ce8e8b07cac721dafac10c971670c26c6e (diff) | |
download | sparse-fe71f6b3064072ba5a6b8531c76b531bbb3b963d.tar.gz |
avoid unneeded alloc on error path
In evaluate_dereference(), a node is allocated but
is not used if there is an error.
Fix this by allocating the node after the error checks.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'evaluate.c')
-rw-r--r-- | evaluate.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -1776,7 +1776,6 @@ static struct symbol *evaluate_dereference(struct expression *expr) if (ctype->type == SYM_NODE) ctype = ctype->ctype.base_type; - node = alloc_symbol(expr->pos, SYM_NODE); target = ctype->ctype.base_type; switch (ctype->type) { @@ -1784,6 +1783,7 @@ static struct symbol *evaluate_dereference(struct expression *expr) expression_error(expr, "cannot dereference this type"); return NULL; case SYM_PTR: + node = alloc_symbol(expr->pos, SYM_NODE); node->ctype.modifiers = target->ctype.modifiers & MOD_SPECIFIER; merge_type(node, ctype); break; @@ -1801,6 +1801,7 @@ static struct symbol *evaluate_dereference(struct expression *expr) * When an array is dereferenced, we need to pick * up the attributes of the original node too.. */ + node = alloc_symbol(expr->pos, SYM_NODE); merge_type(node, op->ctype); merge_type(node, ctype); break; |