ruby-changes:71451
From: Nobuyoshi <ko1@a...>
Date: Fri, 18 Mar 2022 00:42:26 +0900 (JST)
Subject: [ruby-changes:71451] f69a969544 (master): Fix potential memory leak at fiber pool
https://git.ruby-lang.org/ruby.git/commit/?id=f69a969544 From f69a969544d5a3af5c9454aabd953517266ad150 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Wed, 16 Mar 2022 18:41:45 +0900 Subject: Fix potential memory leak at fiber pool Do not "allocate then wrap". It leaks the allocated memory if failed to create the wrapper. --- cont.c | 4 ++-- 1 file 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 = { https://github.com/ruby/ruby/blob/trunk/cont.c#L2845 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 -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/