Guard against a mis-written GOptionArgFunc that has returned FALSE but not
authorTor Lillqvist <tml@novell.com>
Mon, 12 Jan 2009 11:45:52 +0000 (11:45 +0000)
committerTor Lillqvist <tml@src.gnome.org>
Mon, 12 Jan 2009 11:45:52 +0000 (11:45 +0000)
2009-01-12  Tor Lillqvist  <tml@novell.com>

* glib/goption.c (parse_arg): Guard against a mis-written
GOptionArgFunc that has returned FALSE but not set the GError.

svn path=/trunk/; revision=7804

ChangeLog
glib/goption.c

index e58ffbd..3cd3a50 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-01-12  Tor Lillqvist  <tml@novell.com>
+
+       * glib/goption.c (parse_arg): Guard against a mis-written
+       GOptionArgFunc that has returned FALSE but not set the GError.
+
 2009-01-10  Matthias Clasen  <mclasen@redhat.com>
 
        Bug 566573 – g_match_info_fetch_pos docs
index e5bd2ba..fa39b79 100644 (file)
@@ -1150,6 +1150,11 @@ parse_arg (GOptionContext *context,
 
        retval = (* (GOptionArgFunc) entry->arg_data) (option_name, data, group->user_data, error);
        
+       if (!retval && error != NULL && *error == NULL)
+         g_set_error (error, 
+                      G_OPTION_ERROR, G_OPTION_ERROR_FAILED,
+                      _("Error parsing option %s"), option_name);
+
        g_free (data);
        
        return retval;