[seed] Fix Bug# 610765 - test g_arg_info_may_be_null before accepting null



commit d8749191461e427d3b68360781af8b157752d73d
Author: alan <alan alanfast akbkhome com>
Date:   Wed Feb 24 12:31:30 2010 +0800

    Fix Bug# 610765 - test g_arg_info_may_be_null before accepting null
    
    Correct behaviour is to read gir hints on null for arguments - otherwise segfaults happen...
    This does however break a few function calls, that have got broken gir notes,
    eg. gtk_drag_source_set gtk_drag_dest_set and gst_bus_add_watch

 libseed/seed-engine.c |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/libseed/seed-engine.c b/libseed/seed-engine.c
index 8b668e7..848187e 100644
--- a/libseed/seed-engine.c
+++ b/libseed/seed-engine.c
@@ -502,7 +502,22 @@ seed_gobject_method_invoked (JSContextRef ctx,
       else if (dir == GI_DIRECTION_IN || dir == GI_DIRECTION_INOUT)
 	{
 
-	  if (!seed_gi_make_argument (ctx, arguments[i], type_info,
+	  if (  
+		( !arguments[i] || JSValueIsNull (ctx, arguments[i]) ) &&
+		!g_arg_info_may_be_null (arg_info) 
+             )
+            {
+	      seed_make_exception (ctx, exception,
+				   "ArgumentError",
+				   " argument %d must not be null for"
+				   " function: %s. \n",
+				   i + 1,
+				   g_base_info_get_name ((GIBaseInfo *)
+							 info));
+	      goto arg_error;
+
+          }
+          if (!seed_gi_make_argument (ctx, arguments[i], type_info,
 				      &in_args[n_in_args++], exception))
 	    {
 	      seed_make_exception (ctx, exception,
@@ -512,7 +527,7 @@ seed_gobject_method_invoked (JSContextRef ctx,
 				   i + 1,
 				   g_base_info_get_name ((GIBaseInfo *)
 							 info));
-
+ arg_error:
 	      g_base_info_unref ((GIBaseInfo *) type_info);
 	      g_base_info_unref ((GIBaseInfo *) arg_info);
 	      g_free (in_args);



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