mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/fiddle] Fiddle::Function must maintain a reference to the closure
If the first parameter to Fiddle::Function is a closure object (rather
than an interger), `rb_Integer` will cast it to an integer but not
maintain a reference to the closure. Then if the closure gets GC'd, we
have a segv. This commit keeps a reference to the original parameter to
initialize so that the object will not be GC'd.
Fixes: https://bugs.ruby-lang.org/issues/13286
0fc697bbc5
This commit is contained in:
parent
70ca56deda
commit
7733db665a
1 changed files with 2 additions and 0 deletions
|
|
@ -99,6 +99,8 @@ initialize(int argc, VALUE argv[], VALUE self)
|
|||
void *cfunc;
|
||||
|
||||
rb_scan_args(argc, argv, "31:", &ptr, &args, &ret_type, &abi, &kwds);
|
||||
rb_iv_set(self, "@closure", ptr);
|
||||
|
||||
ptr = rb_Integer(ptr);
|
||||
cfunc = NUM2PTR(ptr);
|
||||
PTR2NUM(cfunc);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue