]> spindle.queued.net Git - midori/commitdiff
Check if path is absolute before building exec_path
authorPaweł Forysiuk <tuxator@o2.pl>
Tue, 31 Jul 2012 17:09:59 +0000 (19:09 +0200)
committerChristian Dywan <christian@twotoasts.de>
Fri, 3 Aug 2012 19:07:28 +0000 (21:07 +0200)
midori/midori-app.c

index 1822a91b946fa3813dc017f3424d297b2be707b4..f27562c127333ded99300bb8551484dfa2b3c135 100644 (file)
@@ -1509,9 +1509,22 @@ midori_app_setup (gchar** argument_vector)
     #ifdef G_OS_WIN32
     exec_path = g_win32_get_package_installation_directory_of_module (NULL);
     #else
-    executable = g_file_read_link (command_line[0], NULL);
+    if (!g_path_is_absolute (command_line[0]))
+    {
+        gchar* program = g_find_program_in_path (command_line[0]);
+
+        if (g_file_test (program, G_FILE_TEST_IS_SYMLINK))
+            executable = g_file_read_link (program, NULL);
+        else
+            executable = g_strdup (program);
+
+        g_free (program);
+    }
+    else
+        executable = g_file_read_link (command_line[0], NULL);
+
     exec_path = g_file_get_path (g_file_get_parent (g_file_get_parent (g_file_new_for_path (
-        g_find_program_in_path (executable ? executable : command_line[0])))));
+        executable ? executable : command_line[0]))));
     g_free (executable);
     #endif