aboutsummaryrefslogtreecommitdiffstats
path: root/cont.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2022-03-16 18:41:45 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2022-03-18 00:42:15 +0900
commitf69a969544d5a3af5c9454aabd953517266ad150 (patch)
tree49a8dbaa45a90231fe4b97d99e6eeaffddc90956 /cont.c
parentcdf25cad6bae6173eb3d32e5c41f22ccad8f5fa9 (diff)
downloadruby-f69a969544d5a3af5c9454aabd953517266ad150.tar.gz
Fix potential memory leak at fiber pool
Do not "allocate then wrap". It leaks the allocated memory if failed to create the wrapper.
Diffstat (limited to 'cont.c')
-rw-r--r--cont.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/cont.c b/cont.c
index ab9c8c9e49..667e6846b3 100644
--- a/cont.c
+++ b/cont.c
@@ -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