From e5914dd479a86e2a9af01288d5915c78fa0bfae8 Mon Sep 17 00:00:00 2001 From: shyouhei Date: Tue, 2 Jan 2018 06:41:57 +0000 Subject: fix memory leak (FOUND BY A COMPILER WARNING) Confusion of argument order ignores this st_free_table. Results in garbaged table not GCed. Easily noticable when you read the compiper warnings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61561 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- array.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'array.c') diff --git a/array.c b/array.c index e7f96f7685..fa88f47ae9 100644 --- a/array.c +++ b/array.c @@ -4953,7 +4953,7 @@ rb_ary_sample(int argc, VALUE *argv, VALUE ary) long max_idx = 0; #undef RUBY_UNTYPED_DATA_WARNING #define RUBY_UNTYPED_DATA_WARNING 0 - VALUE vmemo = Data_Wrap_Struct(0, 0, 0, st_free_table); + VALUE vmemo = Data_Wrap_Struct(0, 0, st_free_table, 0); st_table *memo = st_init_numtable_with_size(n); DATA_PTR(vmemo) = memo; result = rb_ary_new_capa(n); -- cgit v1.2.3