aboutsummaryrefslogtreecommitdiffstats
path: root/compile.c
diff options
context:
space:
mode:
authorYuichiro Kaneko <spiketeika@gmail.com>2023-10-01 23:46:19 +0900
committerYuichiro Kaneko <spiketeika@gmail.com>2023-10-02 09:41:45 +0900
commit1ed6fd899769e6cd66a1a3f66b7818d48ba4231b (patch)
treeb5873253ad214e2f150f148f60941616ac1c8139 /compile.c
parent81668579ed0cf90b95f2fcc5755b51842fb65917 (diff)
downloadruby-1ed6fd899769e6cd66a1a3f66b7818d48ba4231b.tar.gz
Check the result of get_nd_recv before node type check for safety
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c6
1 files 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;
}