[tracker/tracker-0.8] tracker-extract: PDF: Don't let the PDF extractor work for more than 5s



commit aa1fde1b95cbff9f3914469bef22e767131a2605
Author: Martyn Russell <martyn lanedo com>
Date:   Thu May 27 12:17:24 2010 +0100

    tracker-extract: PDF: Don't let the PDF extractor work for more than 5s
    
    Fixes NB#167449, don't allow PDF extractor to consume more than 5s

 src/tracker-extract/tracker-extract-pdf.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/src/tracker-extract/tracker-extract-pdf.c b/src/tracker-extract/tracker-extract-pdf.c
index 6db5aee..6dbdba9 100644
--- a/src/tracker-extract/tracker-extract-pdf.c
+++ b/src/tracker-extract/tracker-extract-pdf.c
@@ -226,12 +226,15 @@ extract_content (PopplerDocument *document,
 	GString *string;
 	gint n_pages, i, words;
 	gchar *text, *t;
+	GTimer *timer;
 
 	n_pages = poppler_document_get_n_pages (document);
 	string = g_string_new ("");
 	words = i = 0;
 
-	while (i < n_pages && words < n_words) {
+	timer = g_timer_new ();
+
+	while (i < n_pages && words < n_words && g_timer_elapsed (timer, NULL) < 5) {
 		gint normalized_words;
 
 		page = poppler_document_get_page (document, i);
@@ -251,6 +254,8 @@ extract_content (PopplerDocument *document,
 		g_object_unref (page);
 	}
 
+	g_timer_destroy (timer);
+
 	return g_string_free (string, FALSE);
 }
 



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