diff options
author | Robin Watts <robin.watts@artifex.com> | 2012-04-05 18:01:54 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2012-04-05 18:26:34 +0100 |
commit | e7b13e1de4b29f36ed536bb863e5d81768550490 (patch) | |
tree | 82b9645887a4eb1223f49e76f4f8872204019fa0 /pdf/pdf_function.c | |
parent | ff55e72b741b955bbd0e23bd9d724c6682a181ac (diff) | |
download | mupdf-e7b13e1de4b29f36ed536bb863e5d81768550490.tar.xz |
Fix potential problems on malloc failure.
Don't reset the size of arrays until we have successfully resized them.
Diffstat (limited to 'pdf/pdf_function.c')
-rw-r--r-- | pdf/pdf_function.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/pdf/pdf_function.c b/pdf/pdf_function.c index cbcd8aa7..67c34836 100644 --- a/pdf/pdf_function.c +++ b/pdf/pdf_function.c @@ -692,8 +692,9 @@ resize_code(fz_context *ctx, pdf_function *func, int newsize) { if (newsize >= func->u.p.cap) { - func->u.p.cap = func->u.p.cap + 64; - func->u.p.code = fz_resize_array(ctx, func->u.p.code, func->u.p.cap, sizeof(psobj)); + int new_cap = func->u.p.cap + 64; + func->u.p.code = fz_resize_array(ctx, func->u.p.code, new_cap, sizeof(psobj)); + func->u.p.cap = new_cap; } } |