diff options
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/shell_integration_linux.cc | 12 | ||||
-rw-r--r-- | chrome/browser/shell_integration_unittest.cc | 21 |
2 files changed, 28 insertions, 5 deletions
diff --git a/chrome/browser/shell_integration_linux.cc b/chrome/browser/shell_integration_linux.cc index 25f7401..326a93e 100644 --- a/chrome/browser/shell_integration_linux.cc +++ b/chrome/browser/shell_integration_linux.cc @@ -680,13 +680,15 @@ std::string GetDesktopFileContents( static_cast<GRegexMatchFlags>(0), NULL); gchar** keys = g_key_file_get_keys(key_file, kDesktopEntry, NULL, NULL); - for (gchar** keys_ptr = keys; *keys_ptr; ++keys_ptr) { - if (g_regex_match(localized_key_regex, *keys_ptr, - static_cast<GRegexMatchFlags>(0), NULL)) { - g_key_file_remove_key(key_file, kDesktopEntry, *keys_ptr, NULL); + if (keys != NULL) { + for (gchar** keys_ptr = keys; *keys_ptr; ++keys_ptr) { + if (g_regex_match(localized_key_regex, *keys_ptr, + static_cast<GRegexMatchFlags>(0), NULL)) { + g_key_file_remove_key(key_file, kDesktopEntry, *keys_ptr, NULL); + } } + g_strfreev(keys); } - g_strfreev(keys); g_regex_unref(localized_key_regex); // Set the "Name" key. diff --git a/chrome/browser/shell_integration_unittest.cc b/chrome/browser/shell_integration_unittest.cc index 58b4294..30df2d4 100644 --- a/chrome/browser/shell_integration_unittest.cc +++ b/chrome/browser/shell_integration_unittest.cc @@ -391,6 +391,27 @@ TEST(ShellIntegrationTest, GetDesktopFileContents) { // Dumb case. { "ignored", "ignored", "ignored", false, "", "#!/usr/bin/env xdg-open\n" }, + // Non-empty file without [Desktop Entry]. + // This tests a different code path to the above. + { "http://gmail.com", + "GMail", + "chrome-http__gmail.com", + false, + "\n", + + // The resulting shortcut is not useful, but we just want to make sure + // this doesn't crash. + "#!/usr/bin/env xdg-open\n" + "[Desktop Entry]\n" + "Name=GMail\n" + "Icon=chrome-http__gmail.com\n" +#if !defined(USE_AURA) + // Aura Chrome does not (yet) set WMClass, so we only expect + // StartupWMClass on non-Aura builds. + "StartupWMClass=gmail.com\n" +#endif + }, + // Real-world case. { "http://gmail.com", "GMail", |