diff options
author | Samuel Williams <[email protected]> | 2021-12-20 09:43:22 +1300 |
---|---|---|
committer | Samuel Williams <[email protected]> | 2021-12-21 12:25:42 +1300 |
commit | 71bf5cef75b9d244a06261c9fc0b84fbe5a1592f (patch) | |
tree | 9ecde04f340d154b4860d8004b5e9bf345bf8afb /io_buffer.c | |
parent | 9de5c4ec761aad3edc50b38d9824b40665d18911 (diff) |
Fix handling of frozens strings.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/5303
Diffstat (limited to 'io_buffer.c')
-rw-r--r-- | io_buffer.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/io_buffer.c b/io_buffer.c index a97c687239..d2a12b98fb 100644 --- a/io_buffer.c +++ b/io_buffer.c @@ -279,7 +279,12 @@ rb_io_buffer_type_for(VALUE klass, VALUE string) rb_str_locktmp(string); - io_buffer_initialize(data, RSTRING_PTR(string), RSTRING_LEN(string), RB_IO_BUFFER_EXTERNAL, string); + enum rb_io_buffer_flags flags = RB_IO_BUFFER_EXTERNAL; + + if (RB_OBJ_FROZEN(string)) + flags |= RB_IO_BUFFER_IMMUTABLE; + + io_buffer_initialize(data, RSTRING_PTR(string), RSTRING_LEN(string), flags, string); return instance; } |