From 1ed6fd899769e6cd66a1a3f66b7818d48ba4231b Mon Sep 17 00:00:00 2001 From: Yuichiro Kaneko Date: Sun, 1 Oct 2023 23:46:19 +0900 Subject: [PATCH] Check the result of get_nd_recv before node type check for safety Co-authored-by: Nobuyoshi Nakada --- compile.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compile.c b/compile.c index 40aedde788..6ef27ed1a4 100644 --- a/compile.c +++ b/compile.c @@ -5420,9 +5420,9 @@ compile_cpath(LINK_ANCHOR *const ret, rb_iseq_t *iseq, const NODE *cpath) static inline int private_recv_p(const NODE *node) { - if (nd_type_p(get_nd_recv(node), NODE_SELF)) { - NODE *self = get_nd_recv(node); - return RNODE_SELF(self)->nd_state != 0; + NODE *recv = get_nd_recv(node); + if (recv && nd_type_p(recv, NODE_SELF)) { + return RNODE_SELF(recv)->nd_state != 0; } return 0; }