diff options
| author | Jean Boussier <jean.boussier@gmail.com> | 2026-01-28 13:39:33 +0100 |
|---|---|---|
| committer | Jean Boussier <jean.boussier@gmail.com> | 2026-01-29 23:32:04 +0100 |
| commit | 91619f0230c0e5a95c796c1bd4f784c151e15614 (patch) | |
| tree | b8cf37fc6092a51f318996f382ab9503ba390100 /ext | |
| parent | 457bb11aa5b2ce4424b611acb489686d130261de (diff) | |
gc.c: Verify provided size in `rb_gc_impl_free`
For now the provided size is just for GC statistics, but in the future
we may want to forward it to C23's `free_sized` and passing an incorrect
size to it is undefined behavior.
Diffstat (limited to 'ext')
| -rw-r--r-- | ext/-test-/string/cstr.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/ext/-test-/string/cstr.c b/ext/-test-/string/cstr.c index b0b1ef5374..931220b46b 100644 --- a/ext/-test-/string/cstr.c +++ b/ext/-test-/string/cstr.c @@ -111,9 +111,10 @@ bug_str_s_cstr_noembed(VALUE self, VALUE str) FL_SET((str2), STR_NOEMBED); memcpy(buf, RSTRING_PTR(str), capacity); RBASIC(str2)->flags &= ~(STR_SHARED | FL_USER5 | FL_USER6); - RSTRING(str2)->as.heap.aux.capa = capacity; + RSTRING(str2)->as.heap.aux.capa = RSTRING_LEN(str); RSTRING(str2)->as.heap.ptr = buf; RSTRING(str2)->len = RSTRING_LEN(str); + TERM_FILL(RSTRING_END(str2), TERM_LEN(str)); return str2; } |
