From bfc8b17d64c29f96da7bea57dd73692c4d50e7a1 Mon Sep 17 00:00:00 2001 From: Miciah Dashiel Butler Masters Date: Thu, 15 Jun 2006 22:58:56 +0000 Subject: [PATCH] Fix a bug in the plaintext renderer when handling tabs Commit 3ce3f01f303c25bc21e688a29f10aed73d4c2169 introduced a bug whereby if a tab set the current position in the line to or greater than the number of bytes remaining in the source, the line was split after the tab. --- src/document/plain/renderer.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/document/plain/renderer.c b/src/document/plain/renderer.c index 800ab18c..8c21fa6a 100644 --- a/src/document/plain/renderer.c +++ b/src/document/plain/renderer.c @@ -671,10 +671,12 @@ add_document_lines(struct plain_renderer *renderer) int last_space = 0; int tab_spaces = 0; int step = 0; - int doc_width = int_min(renderer->max_width, length); /* End of line detection: We handle \r, \r\n and \n types. */ - for (width = 0; width + tab_spaces < doc_width; width++) { + for (width = 0; + width + tab_spaces < renderer->max_width + && width < length; + width++) { if (source[width] == ASCII_CR) step++; if (source[width + step] == ASCII_LF)