From c8d05140e00ea60fad0e1892f9f9f7cf9d108be6 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 22 Feb 2018 11:57:43 +0300 Subject: [PATCH] helper: fix segfault parsing invalid code If we're parsing invalid code, then it's possible for expr->cast_expression to be NULL. No one expects that and it causes segfaults in almost every check. Signed-off-by: Dan Carpenter --- smatch_helper.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/smatch_helper.c b/smatch_helper.c index 3aa8f043..0679a8ef 100644 --- a/smatch_helper.c +++ b/smatch_helper.c @@ -688,6 +688,8 @@ struct expression *strip_expr(struct expression *expr) switch (expr->type) { case EXPR_FORCE_CAST: case EXPR_CAST: + if (!expr->cast_expression) + return expr; return strip_expr(expr->cast_expression); case EXPR_PREOP: { struct expression *unop; -- 2.11.4.GIT