summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--ext/dl/lib/dl/func.rb2
-rw-r--r--test/dl/test_func.rb8
3 files changed, 18 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 04d075e4016..98de2399207 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Wed Dec 5 22:13:57 2012 Naohisa Goto <ngotogenome@gmail.com>
+
+ * ext/dl/lib/dl/func.rb (DL::Function#bind): When Fiddle is used,
+ @ptr should be updated. This fixes SEGV raised in DL::Function#call
+ after calling DL::Function#bind. [Bug #7516] [ruby-dev:46708]
+
+ * test/dl/test_func.rb (test_bind): test for the above
+
Wed Dec 5 18:53:00 2012 Masaya Tarui <tarui@ruby-lang.org>
* thread.c (rb_thread_s_async_interrupt_timing): have to check ints
diff --git a/ext/dl/lib/dl/func.rb b/ext/dl/lib/dl/func.rb
index 12885738c7c..69b6ad306e4 100644
--- a/ext/dl/lib/dl/func.rb
+++ b/ext/dl/lib/dl/func.rb
@@ -118,6 +118,8 @@ module DL
@block.call(*args)
end
}.new(@cfunc.ctype, @args, abi, name, block)
+ @ptr = @cfunc
+ return nil
else
if( !block )
raise(RuntimeError, "block must be given.")
diff --git a/test/dl/test_func.rb b/test/dl/test_func.rb
index 514ed6c6c27..b1aac15dd21 100644
--- a/test/dl/test_func.rb
+++ b/test/dl/test_func.rb
@@ -15,6 +15,14 @@ module DL
assert_equal('<callback>qsort', cb.name)
end
+ def test_bind
+ f = Function.new(CFunc.new(0, TYPE_INT, 'test'), [TYPE_INT, TYPE_INT])
+ assert_nothing_raised {
+ f.bind { |x, y| x + y }
+ }
+ assert_equal 579, f.call(123, 456)
+ end
+
def test_to_i
cfunc = CFunc.new(@libc['strcpy'], TYPE_VOIDP, 'strcpy')
f = Function.new(cfunc, [TYPE_VOIDP, TYPE_VOIDP])