diff options
author | Nobuyoshi Nakada <[email protected]> | 2022-03-16 18:41:45 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2022-03-18 00:42:15 +0900 |
commit | f69a969544d5a3af5c9454aabd953517266ad150 (patch) | |
tree | 49a8dbaa45a90231fe4b97d99e6eeaffddc90956 /cont.c | |
parent | cdf25cad6bae6173eb3d32e5c41f22ccad8f5fa9 (diff) |
Fix potential memory leak at fiber pool
Do not "allocate then wrap". It leaks the allocated memory if
failed to create the wrapper.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/5668
Diffstat (limited to 'cont.c')
-rw-r--r-- | cont.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -2845,9 +2845,9 @@ static const rb_data_type_t FiberPoolDataType = { static VALUE fiber_pool_alloc(VALUE klass) { - struct fiber_pool * fiber_pool = RB_ALLOC(struct fiber_pool); + struct fiber_pool *fiber_pool; - return TypedData_Wrap_Struct(klass, &FiberPoolDataType, fiber_pool); + return TypedData_Make_Struct(klass, struct fiber_pool, &FiberPoolDataType, fiber_pool); } static VALUE |