From 9dc6e59d74cdd678cb47d9d2e4bc8b462872bb82 Mon Sep 17 00:00:00 2001 From: "benjhayden@chromium.org" Date: Mon, 20 Aug 2012 17:15:43 +0000 Subject: Prevent crashes in mime_util_xdg. Review URL: https://chromiumcodereview.appspot.com/10831337 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152347 0039d316-1c4b-4281-b951-d872f2087c98 --- base/nix/mime_util_xdg.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'base/nix') diff --git a/base/nix/mime_util_xdg.cc b/base/nix/mime_util_xdg.cc index 030c30c..e58e03d 100644 --- a/base/nix/mime_util_xdg.cc +++ b/base/nix/mime_util_xdg.cc @@ -588,6 +588,8 @@ namespace base { namespace nix { std::string GetFileMimeType(const FilePath& filepath) { + if (filepath.empty()) + return std::string(); base::ThreadRestrictions::AssertIOAllowed(); base::AutoLock scoped_lock(g_mime_util_xdg_lock.Get()); return xdg_mime_get_mime_type_from_file_name(filepath.value().c_str()); @@ -625,7 +627,7 @@ FilePath GetMimeIcon(const std::string& mime_type, size_t size) { std::string icon_name; FilePath icon_file; - { + if (!mime_type.empty()) { base::AutoLock scoped_lock(g_mime_util_xdg_lock.Get()); const char *icon = xdg_mime_get_icon(mime_type.c_str()); icon_name = std::string(icon ? icon : ""); -- cgit v1.1