diff options
author | Aaron Patterson <[email protected]> | 2022-12-02 09:44:10 -0600 |
---|---|---|
committer | Aaron Patterson <[email protected]> | 2022-12-03 13:03:51 -0600 |
commit | dba61f487cd7c1555f1187a2e2846506c1b143be (patch) | |
tree | 46920be506c2a4bac4c934974eb2aadb419f38ec /iseq.c | |
parent | b8a73e704ddc77db36317dda293e99fb0ee641f4 (diff) |
return early if there is no is_entries buffer
If there is a compilation error, is_entries may not be allocated, but
ic_size could be greater than 0. If we don't have a buffer to iterate
over, just return early. Otherwise GC could segv
[Bug #19173]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6853
Diffstat (limited to 'iseq.c')
-rw-r--r-- | iseq.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -126,6 +126,14 @@ remove_from_constant_cache(ID id, IC ic) static void iseq_clear_ic_references(const rb_iseq_t *iseq) { + // In some cases (when there is a compilation error), we end up with + // ic_size greater than 0, but no allocated is_entries buffer. + // If there's no is_entries buffer to loop through, return early. + // [Bug #19173] + if (!ISEQ_BODY(iseq)->is_entries) { + return; + } + for (unsigned int ic_idx = 0; ic_idx < ISEQ_BODY(iseq)->ic_size; ic_idx++) { IC ic = &ISEQ_IS_IC_ENTRY(ISEQ_BODY(iseq), ic_idx); |