ruby-changes:61313
From: Nobuyoshi <ko1@a...>
Date: Fri, 22 May 2020 06:56:05 +0900 (JST)
Subject: [ruby-changes:61313] 79d9528ddc (master): Fixed potential memory leak
https://git.ruby-lang.org/ruby.git/commit/?id=79d9528ddc From 79d9528ddca1dfe2dd99287dc88fd7c2b30f7137 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Fri, 22 May 2020 06:50:23 +0900 Subject: Fixed potential memory leak Create a wrapper object first, then buffer allocation which can fail. diff --git a/compile.c b/compile.c index 1159a9d..a4328d0 100644 --- a/compile.c +++ b/compile.c @@ -9721,12 +9721,13 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/compile.c#L9721 pinned_list_new(long size) { struct pinned_list * ptr; + VALUE obj_list = + TypedData_Make_Struct(0, struct pinned_list, &pinned_list_type, ptr); - ptr = xmalloc(sizeof(struct pinned_list)); - ptr->size = size; ptr->buffer = xcalloc(size, sizeof(VALUE)); + ptr->size = size; - return TypedData_Wrap_Struct(0, &pinned_list_type, ptr); + return obj_list; } static ibf_offset_t diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb index cf67685..cce2967 100644 --- a/lib/rubygems/installer.rb +++ b/lib/rubygems/installer.rb @@ -189,6 +189,7 @@ class Gem::Installer https://github.com/ruby/ruby/blob/trunk/lib/rubygems/installer.rb#L189 if options[:user_install] @gem_home = Gem.user_dir @bin_dir = Gem.bindir gem_home unless options[:bin_dir] + @plugins_dir = Gem.plugindir(gem_home) check_that_user_bin_dir_is_in_path end end -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/