Project

General

Profile

Actions

Bug #20595

closed

Corruption of encoding name string

Added by peterzhu2118 (Peter Zhu) 5 months ago. Updated 5 months ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:118391]

Description

GitHub PR: https://github.com/ruby/ruby/pull/11062

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"]
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0