diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2011-08-25 13:56:09 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2011-08-26 10:56:48 +0100 |
commit | 1a4f1df77eecee053eaae35d5544f151d37342e2 (patch) | |
tree | a7f3735a30feab055b21d7944ac2222cffe0be37 /generator | |
parent | 675f336319058fdbaf11ee004968b4543a5a9815 (diff) | |
download | libguestfs-1a4f1df77eecee053eaae35d5544f151d37342e2.tar.gz libguestfs-1a4f1df77eecee053eaae35d5544f151d37342e2.tar.xz libguestfs-1a4f1df77eecee053eaae35d5544f151d37342e2.zip |
ruby: Check Ruby callback exists before we call it (RHBZ#733297).
Diffstat (limited to 'generator')
-rw-r--r-- | generator/generator_ruby.ml | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/generator/generator_ruby.ml b/generator/generator_ruby.ml index eee6b7e7..38121b57 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; } |