From b81be8d34b179d48e677463bd7b66ffdea129517 Mon Sep 17 00:00:00 2001 From: Paul Gardiner Date: Wed, 4 Jul 2012 15:49:52 +0100 Subject: Forms: avoid infinite loop when laying out multiline text in thin box If the bounding box was too thin for even a sinlge character, the algorithm could repeat for ever throwing new lines. This in turn could lead to a SEGV. --- pdf/pdf_form.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pdf/pdf_form.c b/pdf/pdf_form.c index 3d14208f..3a9c7a46 100644 --- a/pdf/pdf_form.c +++ b/pdf/pdf_form.c @@ -606,6 +606,10 @@ static int text_splitter_layout(fz_context *ctx, text_splitter *splitter) stride = pdf_text_stride(ctx, splitter->info->font, fontsize, (unsigned char *)text, len, room, &count); + /* If not a single char fits although the line is empty, then force one char */ + if (count == 0 && splitter->x == 0.0) + stride = pdf_text_stride(ctx, splitter->info->font, fontsize, (unsigned char *)text, 1, FLT_MAX, &count); + if (count < len && splitter->retry) { /* The word didn't fit and we are in retry mode. Work out the -- cgit v1.2.3