BugĀ 600550 - (...) doesn't treat arguments properly
authorChristian Dywan <christian@lanedo.com>
Thu, 19 Nov 2009 15:58:43 +0000 (09:58 -0600)
committerRyan Lortie <desrt@desrt.ca>
Thu, 19 Nov 2009 16:00:38 +0000 (10:00 -0600)
Add some additional checking to g_app_info_create_from_commandline to
make it handle strange inputs more elegantly.

gio/gdesktopappinfo.c

index 187ce4a..7770444 100644 (file)
@@ -1607,6 +1607,8 @@ g_app_info_create_from_commandline (const char           *commandline,
   char *basename;
   GDesktopAppInfo *info;
 
+  g_return_val_if_fail (commandline, NULL);
+
   info = g_object_new (G_TYPE_DESKTOP_APP_INFO, NULL);
 
   info->filename = NULL;
@@ -1628,7 +1630,7 @@ g_app_info_create_from_commandline (const char           *commandline,
     {
       /* FIXME: this should be more robust. Maybe g_shell_parse_argv and use argv[0] */
       split = g_strsplit (commandline, " ", 2);
-      basename = g_path_get_basename (split[0]);
+      basename = split[0] ? g_path_get_basename (split[0]) : NULL;
       g_strfreev (split);
       info->name = basename;
       if (info->name == NULL)