ruby-changes:16456
From: tarui <ko1@a...>
Date: Sat, 26 Jun 2010 04:43:38 +0900 (JST)
Subject: [ruby-changes:16456] Ruby:r28440 (trunk): * ext/dl/lib/dl/func.rb (call): don't overwrite original arguments
tarui 2010-06-26 04:43:15 +0900 (Sat, 26 Jun 2010) New Revision: 28440 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=28440 Log: * ext/dl/lib/dl/func.rb (call): don't overwrite original arguments to defend from GC. * test/dl/test_func.rb (test_string): add test for above. Modified files: trunk/ChangeLog trunk/ext/dl/lib/dl/func.rb trunk/test/dl/test_func.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 28439) +++ ChangeLog (revision 28440) @@ -1,3 +1,9 @@ +Sat Jun 26 04:39:12 2010 Masaya Tarui <tarui@r...> + + * ext/dl/lib/dl/func.rb (call): don't overwrite original arguments + to defend from GC. + * test/dl/test_func.rb (test_string): add test for above. + Fri Jun 25 11:45:36 2010 James Edward Gray II <jeg2@r...> * lib/csv.rb: Fixing a bug that prevented CSV from parsing Index: ext/dl/lib/dl/func.rb =================================================================== --- ext/dl/lib/dl/func.rb (revision 28439) +++ ext/dl/lib/dl/func.rb (revision 28440) @@ -55,8 +55,8 @@ super else funcs = [] - args = wrap_args(args, @stack.types, funcs, &block) - r = @cfunc.call(@stack.pack(args)) + _args = wrap_args(args, @stack.types, funcs, &block) + r = @cfunc.call(@stack.pack(_args)) funcs.each{|f| f.unbind_at_call()} return wrap_result(r) end Index: test/dl/test_func.rb =================================================================== --- test/dl/test_func.rb (revision 28439) +++ test/dl/test_func.rb (revision 28440) @@ -46,6 +46,18 @@ assert_equal("123", str.to_s) end + def test_string() + stress, GC.stress = GC.stress, true + f = Function.new(CFunc.new(@libc['strcpy'], TYPE_VOIDP, 'strcpy'), + [TYPE_VOIDP, TYPE_VOIDP]) + buff = "000" + str = f.call(buff, "123") + assert_equal("123", buff) + assert_equal("123", str.to_s) + ensure + GC.stress = stress + end + def test_isdigit() f = Function.new(CFunc.new(@libc['isdigit'], TYPE_INT, 'isdigit'), [TYPE_INT]) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/