Project

General

Profile

Actions

Bug #19543

closed

Resizing IO::Buffer to zero bytes fails

Added by hanazuki (Kasumi Hanazuki) about 1 year ago. Updated 9 months ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.3.0dev (2023-03-20T04:02:21Z master 7f696b8859) [x86_64-linux]
[ruby-core:112948]

Description

irb(main):001:0> IO::Buffer.new(1).resize(0)
/home/kasumi/.local/src/github.com/ruby/ruby/-e:1: warning: IO::Buffer is experimental and both the Ruby and C interface may change in the future!
/home/kasumi/.local/src/github.com/ruby/ruby/-e:1: [BUG] rb_sys_fail(rb_io_buffer_resize:realloc) - errno == 0
ruby 3.3.0dev (2023-03-20T04:02:21Z master 7f696b8859) [x86_64-linux]

# full trace is attached to this ticket

IO::Buffer#resize(0) will result in calling realloc(data->base, size) with size = 0 in rb_io_buffer_resize. Zero-sized realloc is deprecated in C (and will be UB in C23).


Files

bug.txt (40 KB) bug.txt hanazuki (Kasumi Hanazuki), 03/20/2023 07:01 AM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0