diff options
author | Kasumi Hanazuki <kasumi@rollingapple.net> | 2023-03-25 08:12:23 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-25 12:12:23 +1300 |
commit | 09295ea796900fb7b05d29e93364090e21598566 (patch) | |
tree | 0d590abbe67939eaaa1b9d7c79a7b31d39aa5322 /CONTRIBUTING.md | |
parent | 59c3fac6c4d803019095eebb92b0d2862450ded6 (diff) | |
download | ruby-09295ea796900fb7b05d29e93364090e21598566.tar.gz |
IO::Buffer#resize: Free internal buffer if new size is zero (#7569)
`#resize(0)` on an IO::Buffer with internal buffer allocated will
result in calling `realloc(data->base, 0)`. The behavior of `realloc`
with size = 0 is implementation-defined (glibc frees the object
and returns NULL, while BSDs return an inaccessible object). And
thus such usage is deprecated in standard C (upcoming C23 will make it
UB).
To avoid this problem, just `free`s the memory when the new size is zero.
Diffstat (limited to 'CONTRIBUTING.md')
0 files changed, 0 insertions, 0 deletions