From 29d5ce762e725d1e6ac69efb02f13b64e98732aa Mon Sep 17 00:00:00 2001 From: Srinivasa Ragavan Date: Mon, 28 Apr 2008 05:36:20 +0000 Subject: Avoid crash while detecting mime types. 2008-04-28 Srinivasa Ragavan * mail/em-utils.c: Avoid crash while detecting mime types. svn path=/trunk/; revision=35426 --- mail/ChangeLog | 4 ++++ mail/em-utils.c | 15 +++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/mail/ChangeLog b/mail/ChangeLog index ca5f536275..45fc8d1b49 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,7 @@ +2008-04-28 Srinivasa Ragavan + + * mail/em-utils.c: Avoid crash while detecting mime types. + 2008-04-28 Srinivasa Ragavan * mail/em-format-html.c: Fix the Mailer header display diff --git a/mail/em-utils.c b/mail/em-utils.c index 73379af0ed..5efa38a9cc 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -2240,6 +2240,7 @@ em_utils_snoop_type(CamelMimePart *part) * that instead and if it returns "application/octet-stream" * try to do better with the filename check. */ + CamelStream *mem; if (magic_type) { if (name_type @@ -2261,12 +2262,14 @@ em_utils_snoop_type(CamelMimePart *part) if (!types_cache) types_cache = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify) g_free, (GDestroyNotify) NULL); - tmp = g_hash_table_lookup (types_cache, res); - if (tmp) { - g_free (res); - res = tmp; - } else { - g_hash_table_insert (types_cache, res, res); + if (res) { + tmp = g_hash_table_lookup (types_cache, res); + if (tmp) { + g_free (res); + res = tmp; + } else { + g_hash_table_insert (types_cache, res, res); + } } return res; -- cgit v1.2.3