diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2011-04-08 23:20:20 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2011-04-08 23:20:20 +0200 |
commit | 7593da5d4b01fc638e54e295ae907b464fe00139 (patch) | |
tree | a7e8d2cfbd045c164b07504189b186dc8b1be82b /fitz/filt_jpxd.c | |
parent | 900a0de43b946152fd11a863c8d997eb928ddd55 (diff) | |
download | mupdf-7593da5d4b01fc638e54e295ae907b464fe00139.tar.xz |
Add soft limit to pixmap allocation.
All image loading functions call the new fz_new_pixmap_with_limit
allocation function, which will return NULL if the total amount of
pixmap memory would exceed a set limit. Other vital pixmap allocations
which are not as easily recoverable (such as font rendering, and the
various buffers in the draw device) ignore the limit.
Diffstat (limited to 'fitz/filt_jpxd.c')
-rw-r--r-- | fitz/filt_jpxd.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/fitz/filt_jpxd.c b/fitz/filt_jpxd.c index 4fb8264d..765aad29 100644 --- a/fitz/filt_jpxd.c +++ b/fitz/filt_jpxd.c @@ -108,7 +108,12 @@ fz_load_jpx_image(fz_pixmap **imgp, unsigned char *data, int size, fz_colorspace } } - img = fz_new_pixmap(colorspace, w, h); + img = fz_new_pixmap_with_limit(colorspace, w, h); + if (!img) + { + opj_image_destroy(jpx); + return fz_throw("out of memory"); + } p = img->samples; for (y = 0; y < h; y++) |