[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.
This commit is contained in:
Peter Zhu 2023-01-06 10:24:09 -05:00
parent 2b88dbc6f9
commit d8ef0a98c6
Notes: git 2023-01-06 16:36:47 +00:00

View File

@ -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);*/