From: David Faust Date: Tue, 7 Dec 2021 19:45:48 +0000 (-0800) Subject: bpf: avoid potential NULL pointer dereference X-Git-Tag: basepoints/gcc-13~2470 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e4c2b55b4cefc574a4c2b0b06928220edb9b3f2c;p=thirdparty%2Fgcc.git bpf: avoid potential NULL pointer dereference If the result from SSA_NAME_DEF_STMT is NULL, we could try to dereference it anyway and ICE. Avoid this. gcc/ChangeLog: * config/bpf/bpf.c (handle_attr_preserve): Avoid calling is_gimple_assign with a NULL pointer. --- diff --git a/gcc/config/bpf/bpf.c b/gcc/config/bpf/bpf.c index 9d2c0bb68188..c054c1ead6b5 100644 --- a/gcc/config/bpf/bpf.c +++ b/gcc/config/bpf/bpf.c @@ -1482,7 +1482,7 @@ handle_attr_preserve (function *fn) && TREE_CODE (TREE_OPERAND (expr, 0)) == SSA_NAME) { gimple *def_stmt = SSA_NAME_DEF_STMT (TREE_OPERAND (expr, 0)); - if (is_gimple_assign (def_stmt)) + if (def_stmt && is_gimple_assign (def_stmt)) expr = gimple_assign_rhs1 (def_stmt); }