summaryrefslogtreecommitdiff
path: root/test/ruby/test_stack.rb
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2024-01-16 09:32:21 -0500
committerPeter Zhu <peter@peterzhu.ca>2024-01-17 08:54:25 -0500
commite17c83e02c5019f7a8c31b31a567ab6de6d6c7f4 (patch)
tree13582bbe1f080f77372a818eb752db61a99c2385 /test/ruby/test_stack.rb
parent67a545b3d2c52fbbf4336e9c2bea662cdfb30bc7 (diff)
Fix memory leak in String#tr and String#tr_s
rb_enc_codepoint_len could raise, which would cause the memory in buf to leak. For example: str1 = "\xE0\xA0\xA1#{" " * 100}".force_encoding("EUC-JP") str2 = "" str3 = "a".force_encoding("Windows-31J") 10.times do 1_000_000.times do str1.tr_s(str2, str3) rescue end puts `ps -o rss= -p #{$$}` end Before: 17536 22752 28032 33312 38688 43968 49200 54432 59744 64992 After: 12176 12352 12352 12448 12448 12448 12448 12448 12448 12448
Diffstat (limited to 'test/ruby/test_stack.rb')
0 files changed, 0 insertions, 0 deletions