Fix Bug# 610765 - test g_arg_info_may_be_null before accepting null
authoralan <alan@alanfast.akbkhome.com>
Wed, 24 Feb 2010 04:31:30 +0000 (12:31 +0800)
committeralan <alan@alanfast.akbkhome.com>
Wed, 24 Feb 2010 04:31:30 +0000 (12:31 +0800)
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

index 8b668e7..848187e 100644 (file)
@@ -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);