diff options
author | Paul Gardiner <paul@glidos.net> | 2012-07-04 15:49:52 +0100 |
---|---|---|
committer | Paul Gardiner <paul@glidos.net> | 2012-07-04 16:48:23 +0100 |
commit | b81be8d34b179d48e677463bd7b66ffdea129517 (patch) | |
tree | 3551c956d9f4c511119e04d72a593d1004c00ea3 | |
parent | 90ec205dd518ad89a3a04c791b3d84a7adf6c561 (diff) | |
download | mupdf-b81be8d34b179d48e677463bd7b66ffdea129517.tar.xz |
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.
-rw-r--r-- | pdf/pdf_form.c | 4 |
1 files changed, 4 insertions, 0 deletions
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 |