merge revision(s) 35e124832e: [Backport #20755]

[Bug #20755] Frozen string should not be writable via IO::Buffer
This commit is contained in:
Takashi Kokubun 2024-11-04 14:39:22 -08:00
parent 12ea98e8c8
commit 5ce0ba0d41
3 changed files with 28 additions and 2 deletions

View file

@ -843,7 +843,8 @@ rb_io_buffer_get_bytes(VALUE self, void **base, size_t *size)
static inline void
io_buffer_get_bytes_for_writing(struct rb_io_buffer *buffer, void **base, size_t *size)
{
if (buffer->flags & RB_IO_BUFFER_READONLY) {
if (buffer->flags & RB_IO_BUFFER_READONLY ||
(!NIL_P(buffer->source) && OBJ_FROZEN(buffer->source))) {
rb_raise(rb_eIOBufferAccessError, "Buffer is not writable!");
}