diff options
| author | Peter Zhu <peter@peterzhu.ca> | 2025-09-10 14:39:52 -0400 |
|---|---|---|
| committer | Peter Zhu <peter@peterzhu.ca> | 2025-09-11 08:14:25 -0400 |
| commit | 729d602e290a3d986c8fc3d178cf1e56f93a88a4 (patch) | |
| tree | 10d3a15909bac4d1e169d27c337d92d0e856194e /internal | |
| parent | 0dc1cd407e7775610f2bcaef6c1282369867f91c (diff) | |
Assert that RARRAY_AREF is within bounds
We should assert that i is within bounds to prevent buffer overflows.
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/array.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/internal/array.h b/internal/array.h index 398676df4a..3a689646fb 100644 --- a/internal/array.h +++ b/internal/array.h @@ -140,6 +140,8 @@ RARRAY_AREF(VALUE ary, long i) VALUE val; RBIMPL_ASSERT_TYPE(ary, RUBY_T_ARRAY); + RUBY_ASSERT(i < RARRAY_LEN(ary)); + RBIMPL_WARNING_PUSH(); #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ == 13 RBIMPL_WARNING_IGNORED(-Warray-bounds); |
