From 0b9a7b35287e7c4db37e0f49612faeff29752108 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Tue, 21 May 2019 14:58:39 +0900 Subject: do not use RARRAY_SET() directly in array.c. --- array.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'array.c') diff --git a/array.c b/array.c index 65c9a96de8..37a6b2b581 100644 --- a/array.c +++ b/array.c @@ -140,7 +140,15 @@ VALUE rb_cArray; FL_SET((ary), RARRAY_SHARED_ROOT_FLAG); \ } while (0) -#define ARY_SET(a, i, v) RARRAY_ASET((assert(!ARY_SHARED_P(a)), (a)), (i), (v)) +static inline void +ARY_SET(VALUE a, long i, VALUE v) +{ + assert(!ARY_SHARED_P(a)); + assert(!OBJ_FROZEN(a)); + + RARRAY_ASET(a, i, v); +} +#undef RARRAY_ASET #if ARRAY_DEBUG @@ -5509,7 +5517,7 @@ yield_indexed_values(const VALUE values, const long r, const long *const p) const VALUE result = rb_ary_new2(r); long i; - for (i = 0; i < r; i++) RARRAY_ASET(result, i, RARRAY_AREF(values, p[i])); + for (i = 0; i < r; i++) ARY_SET(result, i, RARRAY_AREF(values, p[i])); ARY_SET_LEN(result, r); rb_yield(result); return !RBASIC(values)->klass; -- cgit v1.2.3