diff options
author | tarui <tarui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-06-28 16:45:35 +0000 |
---|---|---|
committer | tarui <tarui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-06-28 16:45:35 +0000 |
commit | 6a05e8c5665a264395d5961307f523d3a81a101a (patch) | |
tree | 215d363d0e5e01a869a7cd87889434195c80bb43 | |
parent | 7e80dc06b715d3cf722263b323e6edfd011fbed0 (diff) |
merge from trunk (r28440)
* 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.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@28468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | ext/dl/lib/dl/func.rb | 4 | ||||
-rw-r--r-- | test/dl/test_func.rb | 12 |
3 files changed, 20 insertions, 2 deletions
@@ -1,3 +1,9 @@ +Tue Jun 29 01:44:33 2010 Masaya Tarui <tarui@ruby-lnag.org> + + * 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. + Tue Jun 29 01:41:42 2010 Masaya Tarui <tarui@ruby-lnag.org> * include/ruby/ruby.h (static inline rb_gc_guarded_ptr): prevent diff --git a/ext/dl/lib/dl/func.rb b/ext/dl/lib/dl/func.rb index 4d0db4ee7a..3c2245f413 100644 --- a/ext/dl/lib/dl/func.rb +++ b/ext/dl/lib/dl/func.rb @@ -55,8 +55,8 @@ module DL 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 diff --git a/test/dl/test_func.rb b/test/dl/test_func.rb index ab8353bd76..d438f94506 100644 --- a/test/dl/test_func.rb +++ b/test/dl/test_func.rb @@ -46,6 +46,18 @@ module DL 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]) |