Project

General

Profile

Actions

Bug #22219

open

IO::Buffer#free, #resize and #transfer should raise FrozenError if the receiver is frozen

Bug #22219: IO::Buffer#free, #resize and #transfer should raise FrozenError if the receiver is frozen

Added by himura467 (Akito Shitara) 5 days ago. Updated 5 days ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:126200]

Description

Currently IO::Buffer#free, #resize and #transfer can be called even if the receiver is frozen. All three release, reallocate or hand away the memory the buffer references, so they change the state of the buffer. Therefore it seems a bug to me, and these methods should raise FrozenError if the receiver is frozen.

# Current
IO::Buffer.new(4).freeze.free       # succeeds, the buffer becomes null
IO::Buffer.new(4).freeze.resize(8)  # succeeds, the memory is reallocated
IO::Buffer.new(4).freeze.transfer   # succeeds, the receiver becomes null

# Expected
IO::Buffer.new(4).freeze.free       # raise FrozenError
IO::Buffer.new(4).freeze.resize(8)  # raise FrozenError
IO::Buffer.new(4).freeze.transfer   # raise FrozenError

Methods to fix:

  • IO::Buffer#free
  • IO::Buffer#resize
  • IO::Buffer#transfer
Actions

Also available in: PDF Atom