diff options
| author | Peter Zhu <peter@peterzhu.ca> | 2024-06-26 16:12:53 -0400 |
|---|---|---|
| committer | Peter Zhu <peter@peterzhu.ca> | 2024-06-27 09:47:22 -0400 |
| commit | c6a0d03649c686a537c1f513a1e32205ac6a6512 (patch) | |
| tree | dc5dc20efa563cd4208f82cd7f8aa65f1f53b72d /include/ruby/encoding.h | |
| parent | 815b345b4169f4762510479df6cf73c91362cdeb (diff) | |
Fix corruption of encoding name string
[Bug #20595]
enc_set_default_encoding will free the C string if the encoding is nil,
but the C string can be used by the encoding name string. This will cause
the encoding name string to be corrupted.
Consider the following code:
Encoding.default_internal = Encoding::ASCII_8BIT
names = Encoding.default_internal.names
p names
Encoding.default_internal = nil
p names
It outputs:
["ASCII-8BIT", "BINARY", "internal"]
["ASCII-8BIT", "BINARY", "\x00\x00\x00\x00\x00\x00\x00\x00"]
Co-authored-by: Matthew Valentine-House <matt@eightbitraptor.com>
Diffstat (limited to 'include/ruby/encoding.h')
0 files changed, 0 insertions, 0 deletions
