Blame SOURCES/paps-fix-loop-in-split.patch

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