diff options
author | Peter Zhu <[email protected]> | 2023-01-06 10:24:09 -0500 |
---|---|---|
committer | Peter Zhu <[email protected]> | 2023-01-06 11:36:28 -0500 |
commit | d8ef0a98c670449b20436947f5ebbd327ed5ab0d (patch) | |
tree | 733e9553814c747aeb83e98ad4e9a904f1c9a590 /string.c | |
parent | 2b88dbc6f905a873da1aaead7aed8dcb1fcd3767 (diff) |
[Bug #19319] Fix crash in rb_str_casemap
The following code crashes on my machine:
```
GC.stress = true
str = "testing testing testing"
puts str.capitalize
```
We need to ensure that the object `buffer_anchor` remains on the stack
so it does not get GC'd.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/7080
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -7329,6 +7329,8 @@ rb_str_casemap(VALUE source, OnigCaseFoldType *flags, rb_encoding *enc) DATA_PTR(buffer_anchor) = 0; mapping_buffer_free(current_buffer); + RB_GC_GUARD(buffer_anchor); + /* TODO: check about string terminator character */ str_enc_copy(target, source); /*ENC_CODERANGE_SET(mapped, cr);*/ |