Project

General

Profile

Actions

Bug #20752

closed

IO::Buffer#slice creates mutable IO::Buffer instance that points to readonly memory (e.g. fronzen String)

Added by hanazuki (Kasumi Hanazuki) about 2 months ago. Updated about 2 hours ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 3.4.0dev (2024-09-18T02:16:22Z master 4797b0704a) +PRISM [x86_64-linux]
[ruby-core:119248]

Description

irb(main):001> RUBY_DESCRIPTION.frozen?
=> true
irb(main):002> IO::Buffer.for(RUBY_DESCRIPTION).set_string('perl', 0, 4)
(irb):2:in 'IO::Buffer#set_string': Buffer is not writable! (IO::Buffer::AccessError)
        from (irb):2:in '<main>'
        from <internal:kernel>:191:in 'Kernel#loop'
        from -e:1:in '<main>'
irb(main):003> IO::Buffer.for(RUBY_DESCRIPTION).slice.set_string('perl', 0, 4)
=> 4
irb(main):004> RUBY_DESCRIPTION
=> "perl 3.4.0dev (2024-09-18T02:16:22Z master 4797b0704a) +PRISM [x86_64-linux]"
irb(main):001> IO::Buffer.for(NameError.name).slice.set_string('X', 0, 1)
=> 1
irb(main):002> NameError
(irb):2:in '<main>': uninitialized constant NameError (XameError)
        from <internal:kernel>:191:in 'Kernel#loop'
        from -e:1:in '<main>'
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0