Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(540)

Unified Diff: base/nix/mime_util_xdg.cc

Issue 10831337: Prevent crashes in mime_util_xdg. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/nix/mime_util_xdg.cc
diff --git a/base/nix/mime_util_xdg.cc b/base/nix/mime_util_xdg.cc
index 030c30c11f6559361aed3757461a2d89d4268b95..e58e03dca1e0c04f433ee2ec86088eac41347018 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())
Lei Zhang 2012/08/22 05:59:10 Curious, who is calling GetFileMimeType with an em
benjhayden 2012/08/22 14:24:14 Yes, LoadIcon() doesn't early-return for empty pat
+ 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 : "");
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698