bd0b84e
From 6c3fa9959dd454938378ade2fec8e84cee7d6916 Mon Sep 17 00:00:00 2001
bd0b84e
From: Akira TAGOH <tagoh@redhat.com>
bd0b84e
Date: Tue, 27 Jul 2010 12:19:30 +0900
bd0b84e
Subject: [PATCH 1/2] Fix rhbz#618483: texttopaps becoms runaway memory hog
bd0b84e
bd0b84e
        * src/paps.c (split_text_into_paragraphs): fix a infinite loop
bd0b84e
        when non-printable characters are in the text.
bd0b84e
---
bd0b84e
 src/paps.c |    5 ++++-
bd0b84e
 1 files changed, 4 insertions(+), 1 deletions(-)
bd0b84e
bd0b84e
 	* paps.c: Erased --justify option since it is not implemented in 
bd0b84e
diff --git a/src/paps.c b/src/paps.c
bd0b84e
index 72dbaad..dcef349 100644
bd0b84e
--- a/src/paps.c
bd0b84e
+++ b/src/paps.c
bd0b84e
@@ -835,7 +835,10 @@ split_text_into_paragraphs (PangoContext *pango_context,
bd0b84e
 				      goto fail;
bd0b84e
 			      }
bd0b84e
 			      for (i = 0; i < len; i++) {
bd0b84e
-				      wwidth += wcwidth(wtext[i]);
bd0b84e
+				      gssize w = wcwidth(wtext[i]);
bd0b84e
+
bd0b84e
+				      if (w >= 0)
bd0b84e
+					      wwidth += w;
bd0b84e
 				      if (wwidth > col)
bd0b84e
 					      break;
bd0b84e
 				      wnewtext[i] = wtext[i];
bd0b84e
-- 
bd0b84e
1.7.1.1
bd0b84e