Ensure T_DATA before RTYPEDDATA_P

For the precondition of `RTYPEDDATA_P` that the argument must be a
Ruby object of `::RUBY_T_DATA`.
This commit is contained in:
Nobuyoshi Nakada 2025-12-28 13:38:39 +09:00
parent eaa83e505f
commit 68cd46353c
No known key found for this signature in database
GPG Key ID: 3582D74E1FEE4465
Notes: git 2025-12-28 18:41:56 +00:00

View File

@ -332,7 +332,9 @@ RBIMPL_ATTR_PURE_UNLESS_DEBUG()
static inline const rb_random_interface_t *
rb_rand_if(VALUE obj)
{
RBIMPL_ASSERT_OR_ASSUME(RB_TYPE_P(obj, T_DATA));
RBIMPL_ASSERT_OR_ASSUME(RTYPEDDATA_P(obj));
RUBY_ASSERT(rb_typeddata_is_kind_of(obj, &rb_random_data_type));
const struct rb_data_type_struct *t = RTYPEDDATA_TYPE(obj);
const void *ret = t->data;
return RBIMPL_CAST((const rb_random_interface_t *)ret);