diff options
author | Philip Van Hoof <philip@codeminded.be> | 2014-03-07 21:18:45 +0100 |
---|---|---|
committer | Philip Van Hoof <philip@codeminded.be> | 2014-03-12 10:35:50 +0100 |
commit | 2e42162ac5aabfd4220e4ce7506e2816e313ef77 (patch) | |
tree | 044a1a991a24a7c8ebfd54c00ed91f0a9c83e4f4 | |
parent | 4201fdd235af73c0e2658027fc505ebc7230127f (diff) | |
download | tracker-jolla-upstreaming.tar.gz |
Fix handling when no match is found by libicu charset detectorjolla-upstreaming
-rw-r--r-- | src/libtracker-extract/tracker-encoding-libicu.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/libtracker-extract/tracker-encoding-libicu.c b/src/libtracker-extract/tracker-encoding-libicu.c index 13327e353..feec102d2 100644 --- a/src/libtracker-extract/tracker-encoding-libicu.c +++ b/src/libtracker-extract/tracker-encoding-libicu.c @@ -35,6 +35,7 @@ tracker_encoding_guess_icu (const gchar *buffer, const UCharsetMatch *match; gchar *charset = NULL; UErrorCode status; + const char *p_match = NULL; detector = ucsdet_open (&status); @@ -51,15 +52,15 @@ tracker_encoding_guess_icu (const gchar *buffer, match = ucsdet_detect (detector, &status); - if (U_FAILURE (status)) + if (match == NULL || U_FAILURE (status)) goto failure; - charset = g_strdup (ucsdet_getName (match, &status)); + p_match = ucsdet_getName (match, &status); + + if (p_match == NULL || U_FAILURE (status)) + goto failure; - if (U_FAILURE (status)) { - g_free (charset); - charset = NULL; - } + charset = g_strdup ((const gchar *) p_match); if (charset) g_debug ("Guessing charset as '%s'", charset); |