Issue #22301 has been reported by himura467 (Akito Shitara). ---------------------------------------- Bug #22301: Writing to the contents of a frozen IO::Buffer does not raise FrozenError https://bugs.ruby-lang.org/issues/22301 * Author: himura467 (Akito Shitara) * Status: Open * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- Writing to the contents of a frozen `IO::Buffer` does not raise `FrozenError`: ```ruby buffer = IO::Buffer.new(8) buffer.freeze buffer.set_string("x", 0) # no FrozenError buffer.get_string # => "x\x00\x00\x00\x00\x00\x00\x00" ``` `io_buffer_validate_for_writing()` rejects a buffer whose `RB_IO_BUFFER_READONLY` flag is set, or whose source is frozen, so it already treats frozen as not writable. But it takes a `struct rb_io_buffer *`, so the receiver never reaches it and the buffer's own frozen state goes unchecked. Reachable from `#set_string`, `#copy`, `#clear`, `#set_value`, `#set_values`, `#and!`, `#or!`, `#xor!`, `#not!`, `#read` and `#pread`. `#free`, `#resize` and `#transfer` already raise as of [Bug #22219]. -- https://bugs.ruby-lang.org/