[tracker/tracker-0.8] Fixes GB#623836: Avoid crashing if table of pieces is empty in the msword file
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/tracker-0.8] Fixes GB#623836: Avoid crashing if table of pieces is empty in the msword file
- Date: Fri, 16 Jul 2010 10:14:18 +0000 (UTC)
commit 34f6ec0b9becaaee9f651c767b33341e74dcd66e
Author: Aleksander Morgado <aleksander lanedo com>
Date: Thu Jul 8 17:12:30 2010 +0200
Fixes GB#623836: Avoid crashing if table of pieces is empty in the msword file
src/tracker-extract/tracker-extract-msoffice.c | 16 +++++++++++++---
1 files changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/src/tracker-extract/tracker-extract-msoffice.c b/src/tracker-extract/tracker-extract-msoffice.c
index c9c2de9..3e0c1ac 100644
--- a/src/tracker-extract/tracker-extract-msoffice.c
+++ b/src/tracker-extract/tracker-extract-msoffice.c
@@ -420,9 +420,11 @@ msoffice_convert_and_normalize_chunk (guint8 *buffer,
g_return_if_fail (p_content != NULL);
/* chunks can have different encoding
- * TODO: Using g_iconv, this extra heap allocation could be
- * avoided, re-using over and over again the same output buffer
- * for the UTF-8 encoded string */
+ *
+ * TODO: Using g_iconv, this extra heap allocation could be
+ * avoided, re-using over and over again the same output buffer
+ * for the UTF-8 encoded string
+ */
converted_text = g_convert (buffer,
chunk_size,
"UTF-8",
@@ -914,6 +916,14 @@ extract_msword_content (GsfInfile *infile,
gsf_input_read (document_stream, 4, tmp_buffer);
lcbClx = read_32bit (tmp_buffer);
+ /* If we got an invalid or empty length of piece table, just return
+ * as we cannot iterate over pieces */
+ if (lcbClx <= 0) {
+ g_object_unref (document_stream);
+ g_object_unref (table_stream);
+ return NULL;
+ }
+
/* copy the structure holding the piece table into the clx array. */
clx = g_malloc (lcbClx);
gsf_input_seek (table_stream, fcClx, G_SEEK_SET);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]