summaryrefslogtreecommitdiff
path: root/source/html
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@gmail.com>2017-08-08 19:26:34 +0800
committerSebastian Rasmussen <sebras@gmail.com>2017-08-10 22:12:02 +0800
commite73593152c5d9ac1642af14230e0a346f634cdd2 (patch)
treea2015e69c6934976e82dbe5006aacabf91977108 /source/html
parent09d3d93b4e3d8951bf958f2404ee27b5a0769cb9 (diff)
downloadmupdf-e73593152c5d9ac1642af14230e0a346f634cdd2.tar.xz
Bug 697988: Make sure to extend buffer to accomodate all text.
Diffstat (limited to 'source/html')
-rw-r--r--source/html/html-layout.c8
1 files 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;
}