[tracker] Fix handling when no match is found by libicu charset detector
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] Fix handling when no match is found by libicu charset detector
- Date: Tue, 25 Mar 2014 09:18:34 +0000 (UTC)
commit 9d4cc5631dd87691334081cbb4bd60abfdf8c544
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]