Skip to content

Commit

Permalink
Add missing RB_GC_GUARDs related to DATA_PTR
Browse files Browse the repository at this point in the history
I discovered the problem in `compile.c` from a failing
TestIseqLoad#test_stressful_roundtrip test with ASAN enabled. The other
two changes in array.c and string.c I found by auditing similar usages
of DATA_PTR in the codebase.

[Bug #20402]
  • Loading branch information
KJTsanaktsidis committed Mar 31, 2024
1 parent 174b671 commit 9d0a514
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions array.c
Original file line number Diff line number Diff line change
Expand Up @@ -6643,6 +6643,7 @@ ary_sample(rb_execution_context_t *ec, VALUE ary, VALUE randgen, VALUE nv, VALUE
});
DATA_PTR(vmemo) = 0;
st_free_table(memo);
RB_GC_GUARD(vmemo);
}
else {
result = rb_ary_dup(ary);
Expand Down
1 change: 1 addition & 0 deletions compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -11318,6 +11318,7 @@ iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *const anchor,
}
}
DATA_PTR(labels_wrapper) = 0;
RB_GC_GUARD(labels_wrapper);
validate_labels(iseq, labels_table);
if (!ret) return ret;
return iseq_setup(iseq, anchor);
Expand Down
1 change: 1 addition & 0 deletions string.c
Original file line number Diff line number Diff line change
Expand Up @@ -1148,6 +1148,7 @@ str_cat_conv_enc_opts(VALUE newstr, long ofs, const char *ptr, long len,
rb_str_resize(newstr, olen);
}
DATA_PTR(econv_wrapper) = 0;
RB_GC_GUARD(econv_wrapper);
rb_econv_close(ec);
switch (ret) {
case econv_finished:
Expand Down

0 comments on commit 9d0a514

Please sign in to comment.