summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorgburanov <gburanov@gmail.com>2015-04-22 12:06:49 -0700
committerCommit bot <commit-bot@chromium.org>2015-04-22 19:07:06 +0000
commitc432cac0a0beb77c63081536fc9d53b40e642cbf (patch)
tree54086fde4c51b1e58ae1bf3bf4028dd18e182343 /base
parente901997409f6c3c1720307936a7d65439e50650d (diff)
downloadchromium_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.chromium6
-rw-r--r--base/third_party/xdg_mime/free_pointer_later.patch22
-rw-r--r--base/third_party/xdg_mime/xdgmime.c8
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 *