diff options
author | gburanov <gburanov@gmail.com> | 2015-04-22 12:06:49 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-22 19:07:06 +0000 |
commit | c432cac0a0beb77c63081536fc9d53b40e642cbf (patch) | |
tree | 54086fde4c51b1e58ae1bf3bf4028dd18e182343 /base | |
parent | e901997409f6c3c1720307936a7d65439e50650d (diff) | |
download | chromium_src-c432cac0a0beb77c63081536fc9d53b40e642cbf.zip chromium_src-c432cac0a0beb77c63081536fc9d53b40e642cbf.tar.gz chromium_src-c432cac0a0beb77c63081536fc9d53b40e642cbf.tar.bz2 |
small patch that fixes potential crash in xdg_mime_get_mime_type_for_file() - use of pointer after being freed.
BUG=
Review URL: https://codereview.chromium.org/1037023002
Cr-Commit-Position: refs/heads/master@{#326352}
Diffstat (limited to 'base')
-rw-r--r-- | base/third_party/xdg_mime/README.chromium | 6 | ||||
-rw-r--r-- | base/third_party/xdg_mime/free_pointer_later.patch | 22 | ||||
-rw-r--r-- | base/third_party/xdg_mime/xdgmime.c | 8 |
3 files changed, 30 insertions, 6 deletions
diff --git a/base/third_party/xdg_mime/README.chromium b/base/third_party/xdg_mime/README.chromium index 29d239a..95f3a96 100644 --- a/base/third_party/xdg_mime/README.chromium +++ b/base/third_party/xdg_mime/README.chromium @@ -7,5 +7,7 @@ git://anongit.freedesktop.org/xdg/xdgmime @ 2cdd8d36d7930d5a594587286cb1949ff62f7027 on 2012/08/06. In addition, we have the following patch(es): -- compile.patch: small tweaks to make the code compile. -- Added a LICENSE file. + - compile.patch: small tweaks to make the code compile. + - free_pointer_later.patch: small patch that fixes potential crash in + xdg_mime_get_mime_type_for_file() - use of pointer after being freed. + - Added a LICENSE file. diff --git a/base/third_party/xdg_mime/free_pointer_later.patch b/base/third_party/xdg_mime/free_pointer_later.patch new file mode 100644 index 0000000..7668761 --- /dev/null +++ b/base/third_party/xdg_mime/free_pointer_later.patch @@ -0,0 +1,22 @@ +diff --git a/base/third_party/xdg_mime/xdgmime.c b/base/third_party/xdg_mime/xdgmime.c +index c7b16bb..6dc58c2 100644 +--- a/base/third_party/xdg_mime/xdgmime.c ++++ b/base/third_party/xdg_mime/xdgmime.c +@@ -558,13 +558,13 @@ xdg_mime_get_mime_type_for_file (const char *file_name, + mime_type = _xdg_mime_magic_lookup_data (global_magic, data, bytes_read, NULL, + mime_types, n); + +- free (data); + fclose (file); + +- if (mime_type) +- return mime_type; ++ if (!mime_type) ++ mime_type = _xdg_binary_or_text_fallback(data, bytes_read); + +- return _xdg_binary_or_text_fallback(data, bytes_read); ++ free (data); ++ return mime_type; + } + + const char * diff --git a/base/third_party/xdg_mime/xdgmime.c b/base/third_party/xdg_mime/xdgmime.c index c7b16bb..6dc58c2 100644 --- a/base/third_party/xdg_mime/xdgmime.c +++ b/base/third_party/xdg_mime/xdgmime.c @@ -558,13 +558,13 @@ xdg_mime_get_mime_type_for_file (const char *file_name, mime_type = _xdg_mime_magic_lookup_data (global_magic, data, bytes_read, NULL, mime_types, n); - free (data); fclose (file); - if (mime_type) - return mime_type; + if (!mime_type) + mime_type = _xdg_binary_or_text_fallback(data, bytes_read); - return _xdg_binary_or_text_fallback(data, bytes_read); + free (data); + return mime_type; } const char * |