From 569e75023c7cdc9b10fbf662ed7d9b8f2e27457d Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 11 Nov 2014 14:16:43 +0300 Subject: [PATCH] helper: segfault because of strip_expr() This wasn't handling code like "2 ?: -1" correctly. Signed-off-by: Dan Carpenter --- smatch_helper.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/smatch_helper.c b/smatch_helper.c index 7414aafc..13726256 100644 --- a/smatch_helper.c +++ b/smatch_helper.c @@ -430,8 +430,11 @@ struct expression *strip_expr(struct expression *expr) return strip_expr(expr->unop); return expr; case EXPR_CONDITIONAL: - if (known_condition_true(expr->conditional)) - return strip_expr(expr->cond_true); + if (known_condition_true(expr->conditional)) { + if (expr->cond_true) + return strip_expr(expr->cond_true); + return strip_expr(expr->conditional); + } if (known_condition_false(expr->conditional)) return strip_expr(expr->cond_false); return expr; -- 2.11.4.GIT