diff options
author | Sebastian Rasmussen <sebras@gmail.com> | 2017-08-08 19:26:34 +0800 |
---|---|---|
committer | Sebastian Rasmussen <sebras@gmail.com> | 2017-08-10 22:12:02 +0800 |
commit | e73593152c5d9ac1642af14230e0a346f634cdd2 (patch) | |
tree | a2015e69c6934976e82dbe5006aacabf91977108 | |
parent | 09d3d93b4e3d8951bf958f2404ee27b5a0769cb9 (diff) | |
download | mupdf-e73593152c5d9ac1642af14230e0a346f634cdd2.tar.xz |
Bug 697988: Make sure to extend buffer to accomodate all text.
-rw-r--r-- | source/html/html-layout.c | 8 |
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; } |