зеркало из https://github.com/github/ruby.git
[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 https://github.com/ruby/fiddle/commit/0fc697bbc5
This commit is contained in:
Родитель
70ca56deda
Коммит
7733db665a
|
@ -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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче