[tracker] Fixes GB#623836: Avoid crashing if table of pieces is empty in the msword file



commit a0f02d59ebedfcef1eb4e5e0ae2958b811b8beb2
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 |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/src/tracker-extract/tracker-extract-msoffice.c b/src/tracker-extract/tracker-extract-msoffice.c
index 1d16705..a38c76e 100644
--- a/src/tracker-extract/tracker-extract-msoffice.c
+++ b/src/tracker-extract/tracker-extract-msoffice.c
@@ -419,7 +419,7 @@ msoffice_convert_and_normalize_chunk (guint8    *buffer,
 	 *
 	 * 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 
+	 * for the UTF-8 encoded string
 	 */
 	converted_text = g_convert (buffer,
 	                            chunk_size,
@@ -846,6 +846,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]