Blob Blame History Raw
From 6c3fa9959dd454938378ade2fec8e84cee7d6916 Mon Sep 17 00:00:00 2001
From: Akira TAGOH <tagoh@redhat.com>
Date: Tue, 27 Jul 2010 12:19:30 +0900
Subject: [PATCH 1/2] Fix rhbz#618483: texttopaps becoms runaway memory hog

        * src/paps.c (split_text_into_paragraphs): fix a infinite loop
        when non-printable characters are in the text.
---
 src/paps.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

 	* paps.c: Erased --justify option since it is not implemented in 
diff --git a/src/paps.c b/src/paps.c
index 72dbaad..dcef349 100644
--- a/src/paps.c
+++ b/src/paps.c
@@ -835,7 +835,10 @@ split_text_into_paragraphs (PangoContext *pango_context,
 				      goto fail;
 			      }
 			      for (i = 0; i < len; i++) {
-				      wwidth += wcwidth(wtext[i]);
+				      gssize w = wcwidth(wtext[i]);
+
+				      if (w >= 0)
+					      wwidth += w;
 				      if (wwidth > col)
 					      break;
 				      wnewtext[i] = wtext[i];
-- 
1.7.1.1