diff options
| author | Peter Zhu <peter@peterzhu.ca> | 2025-10-22 19:47:20 -0400 |
|---|---|---|
| committer | Peter Zhu <peter@peterzhu.ca> | 2025-10-24 18:34:13 -0400 |
| commit | cb302881629f997f403e705425f69e5f6b0741ac (patch) | |
| tree | 2ad53ea8e1a5f12ee116de5d6fbc32a41a1b7bbc /include/ruby | |
| parent | fcae206232d923af0de7b0df3917e28f36e116f1 (diff) | |
Fix memory leak of transcoding when fallback raises
When the fallback function in transcode_loop raises, it will leak the memory
in rb_econv_t. The following script reproduces the leak:
10.times do
100_000.times do
"\ufffd".encode(Encoding::US_ASCII, fallback: proc { raise })
rescue
end
puts `ps -o rss= -p #{$$}`
end
Before:
451196
889980
1328508
1767676
2206460
2645372
3083900
3522428
3960956
4399484
After:
12508
12636
12892
12892
13148
13404
13532
13788
13916
13916
Diffstat (limited to 'include/ruby')
0 files changed, 0 insertions, 0 deletions
