diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@looxix.net> | 2005-06-27 01:42:51 +0200 |
|---|---|---|
| committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-06-26 17:21:18 -0700 |
| commit | e2559ab1f5d44c4708c60ff8cae240a854b56d34 (patch) | |
| tree | d24d7145b4113fadbd6204f51f0ff6baec28a38c | |
| parent | 0feb9170ed4aad6a2c54f2850eb3d845cde77845 (diff) | |
| download | sparse-dev-e2559ab1f5d44c4708c60ff8cae240a854b56d34.tar.gz | |
[PATCH] avoid segafult after parse errors in casts
Avoid deferencing a null pointer after parse errors in casts.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@looxix.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
| -rw-r--r-- | linearize.c | 3 | ||||
| -rw-r--r-- | validation/bad-cast.c | 6 |
2 files changed, 9 insertions, 0 deletions
diff --git a/linearize.c b/linearize.c index 44521f60..6a6b6405 100644 --- a/linearize.c +++ b/linearize.c @@ -1452,6 +1452,9 @@ pseudo_t linearize_cast(struct entrypoint *ep, struct expression *expr) pseudo_t src; struct expression *orig = expr->cast_expression; + if (!orig) + return VOID; + src = linearize_expression(ep, orig); return cast_pseudo(ep, src, orig->ctype, expr->ctype); } diff --git a/validation/bad-cast.c b/validation/bad-cast.c new file mode 100644 index 00000000..bafd5a25 --- /dev/null +++ b/validation/bad-cast.c @@ -0,0 +1,6 @@ +struct st; + +static int foo(int a) +{ + return (struct/st *) a; +} |
