[PATCH] Check for NULL stmt in check_all_func_returns

[email protected]
Newsgroups org.kernel.vger.smatch
Message-ID <[email protected]>
From: John Levon <[email protected]>

Sometimes, there's nothing on the statement stack.

Signed-off-by: John Levon <[email protected]>
Suggested-by: Toomas Soome <[email protected]>
---
 check_all_func_returns.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/check_all_func_returns.c b/check_all_func_returns.c
index f9d77449..1ff50433 100644
--- a/check_all_func_returns.c
+++ b/check_all_func_returns.c
@@ -74,7 +74,7 @@ static void check_func_return(struct expression *expr)
 
 	stmt = last_ptr_list((struct ptr_list *)big_statement_stack);
 
-	if (stmt->type == STMT_EXPRESSION && stmt->expression == expr)
+	if (stmt && stmt->type == STMT_EXPRESSION && stmt->expression == expr)
 		sm_error("unchecked function return '%s'", expr_to_str(expr->fn));
 }
 
-- 
2.23.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.