From e73593152c5d9ac1642af14230e0a346f634cdd2 Mon Sep 17 00:00:00 2001 From: Sebastian Rasmussen Date: Tue, 8 Aug 2017 19:26:34 +0800 Subject: Bug 697988: Make sure to extend buffer to accomodate all text. --- source/html/html-layout.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/html/html-layout.c b/source/html/html-layout.c index 583464ed..fe9fbf22 100644 --- a/source/html/html-layout.c +++ b/source/html/html-layout.c @@ -2614,9 +2614,13 @@ detect_flow_directionality(fz_context *ctx, fz_pool *pool, uni_buf *buffer, fz_b /* Make sure the buffer is large enough */ if (buffer->len + len > buffer->cap) { - size_t newcap = buffer->cap * 2; - if (newcap == 0) + size_t newcap = buffer->cap; + if (newcap < 128) newcap = 128; /* Sensible small default */ + + while (newcap < buffer->len + len) + newcap = (newcap * 3) / 2; + buffer->data = fz_resize_array(ctx, buffer->data, newcap, sizeof(uint32_t)); buffer->cap = newcap; } -- cgit v1.2.3