[perl-Glib-Object-Introspection] Do not pass on an incorrect destroy notify func if there is no callback



commit 8d88bddf6eb7e5e85567ad0a7bd896a0f8f7b029
Author: Torsten SchÃnfeld <kaffeetisch gmx de>
Date:   Sun May 13 13:01:09 2012 +0200

    Do not pass on an incorrect destroy notify func if there is no callback
    
    If the user specifies undef or nothing at all for a callback, we must not pass
    on our destroy notify func.  Otherwise, we produce invalid free calls.

 NEWS                  |    2 ++
 gperl-i11n-invoke-c.c |    6 +++++-
 2 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/NEWS b/NEWS
index f302639..ae78744 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,8 @@ Overview of changes in Glib::Object::Introspection <next>
 ========================================================
 
 * Allow setting boxed fields to undef.
+* Do not pass on an incorrect destroy notify func if there is no
+  callback.
 
 Overview of changes in Glib::Object::Introspection 0.008
 ========================================================
diff --git a/gperl-i11n-invoke-c.c b/gperl-i11n-invoke-c.c
index e87056f..1b3d57f 100644
--- a/gperl-i11n-invoke-c.c
+++ b/gperl-i11n-invoke-c.c
@@ -267,7 +267,11 @@ handle_automatic_arg (guint pos,
 		if (pos == cinfo->destroy_pos) {
 			dwarn ("  setting automatic arg %d (destroy notify for calllback %p)\n",
 			       pos, cinfo);
-			arg->v_pointer = release_perl_callback;
+			/* If the code pointer is NULL, then the user actually
+			 * specified undef for the callback or nothing at all,
+			 * in which case we must not install our destroy notify
+			 * handler. */
+			arg->v_pointer = cinfo->code ? release_perl_callback : NULL;
 			return;
 		}
 	}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]