diff options
author | Jean Boussier <[email protected]> | 2024-10-29 18:55:22 +0100 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2024-11-01 13:04:24 +0900 |
commit | d329896fb590de96832d522b475404cae1279767 (patch) | |
tree | d9d0950924ac1e97c10ebb58ccc5dcfa621d2e10 /ext/json/parser/parser.rl | |
parent | 783dde2159a3689ad2d3ef6b7d0005a7cf80adba (diff) |
[ruby/json] Fix a memory leak in #to_json methods
Fix: https://github.com/ruby/json/issues/460
The various `to_json` methods must rescue exceptions
to free the buffer.
```
require 'json'
data = 10_000.times.to_a << BasicObject.new
20.times do
100.times do
begin
data.to_json
rescue NoMethodError
end
end
puts `ps -o rss= -p #{$$}`
end
```
```
20128
24992
29920
34672
39600
44336
49136
53936
58816
63616
68416
73232
78032
82896
87696
92528
97408
102208
107008
111808
```
https://github.com/ruby/json/commit/d227d225ca
Diffstat (limited to 'ext/json/parser/parser.rl')
0 files changed, 0 insertions, 0 deletions