From: Richard W.M. Jones Date: Thu, 25 Aug 2011 12:56:09 +0000 (+0100) Subject: ruby: Check Ruby callback exists before we call it (RHBZ#733297). X-Git-Tag: 1.12.5~7 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=2fd3d215c4f6c6c24d16673a1401a484e7bfb965;p=libguestfs.git ruby: Check Ruby callback exists before we call it (RHBZ#733297). (cherry picked from commit 1a4f1df77eecee053eaae35d5544f151d37342e2) --- diff --git a/generator/generator_ruby.ml b/generator/generator_ruby.ml index eee6b7e..38121b5 100644 --- a/generator/generator_ruby.ml +++ b/generator/generator_ruby.ml @@ -246,13 +246,21 @@ ruby_event_callback_wrapper_wrapper (VALUE argvv) VALUE fn, eventv, event_handlev, bufv, arrayv; fn = argv[0]; - eventv = argv[1]; - event_handlev = argv[2]; - bufv = argv[3]; - arrayv = argv[4]; - rb_funcall (fn, rb_intern (\"call\"), 4, - eventv, event_handlev, bufv, arrayv); + /* Check the Ruby callback still exists. For reasons which are not + * fully understood, even though we registered this as a global root, + * it is still possible for the callback to go away (fn value remains + * but its type changes from T_DATA to T_NONE). (RHBZ#733297) + */ + if (rb_type (fn) != T_NONE) { + eventv = argv[1]; + event_handlev = argv[2]; + bufv = argv[3]; + arrayv = argv[4]; + + rb_funcall (fn, rb_intern (\"call\"), 4, + eventv, event_handlev, bufv, arrayv); + } return Qnil; }