aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/evaluate.c
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-03-02 10:51:33 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-05-19 05:28:31 +0200
commitfee3d01d7ac170e7e90b8cd7f4923dbf3de8df7c (patch)
treefec490477cce3c31e18b1735ecb6f82f177a3523 /evaluate.c
parente35efe330c6ae7d154197c29b127560d569016d0 (diff)
downloadsparse-dev-fee3d01d7ac170e7e90b8cd7f4923dbf3de8df7c.tar.gz
returns the correct type when evaluating NULL
In evaluate_cast(), the expression '(void*)<some zero constant>', aka 'NULL', is detected and given the type 'null_ctype', a special kind of pointer type. However the returned type is the original one: 'void *'. This doesn't seem to be intented as in all other cases, the evaluate_...() functions and ultimately evaluate_expression() always return the type of the expression. Fix this by returning the type given to the expression: null_ctype. Reported-by: Dibyendu Majumdar <mobile@majumdar.org.uk> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'evaluate.c')
-rw-r--r--evaluate.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/evaluate.c b/evaluate.c
index 97685791..60ba6ebd 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -2851,7 +2851,7 @@ static struct symbol *evaluate_cast(struct expression *expr)
expr->type = EXPR_VALUE;
expr->ctype = &null_ctype;
expr->value = 0;
- return ctype;
+ return expr->ctype;
}
}
}