[tracker/jolla-upstreaming: 4/4] Fix handling when no match is found by libicu charset detector



commit 2e42162ac5aabfd4220e4ce7506e2816e313ef77
Author: Philip Van Hoof <philip codeminded be>
Date:   Fri Mar 7 21:18:45 2014 +0100

    Fix handling when no match is found by libicu charset detector

 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 13327e3..feec102 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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]