Actions
Bug #20755
closedIO::Buffer#transfer transfers mutable reference to String's memory but not lock ownership
Bug #20755:
IO::Buffer#transfer transfers mutable reference to String's memory but not lock ownership
ruby -v:
ruby 3.4.0dev (2024-09-18T02:16:22Z master 4797b0704a) +PRISM [x86_64-linux]
Backport:
Description
IO::Buffer.for with a block yields a mutable IO::Buffer that shares underlying memory with a mutable String. While the block is executed, the String instance is temporarily locked and cannot be modified or frozen.
If you call #transfer on the yielded IO::Buffer in the block, however, a mutable IO::Buffer can be escaped from the .for method. Through this IO::Buffer instance, you can modify the underlying String memory even after the String instance is frozen.
Actions