diff options
author | Sebastian Rasmussen <sebras@gmail.com> | 2018-05-09 22:15:11 +0800 |
---|---|---|
committer | Sebastian Rasmussen <sebras@gmail.com> | 2018-05-10 01:16:28 +0800 |
commit | e6dfa88940aec6820411fc0d013c2bd0faa5547e (patch) | |
tree | 81c7fc7c0a74e10463803b7dd625edccd3fc0f37 /source/fitz | |
parent | 8fb0e3989a6867b67d5cafb04b622701d383a832 (diff) | |
download | mupdf-e6dfa88940aec6820411fc0d013c2bd0faa5547e.tar.xz |
Use fz_malloc_no_throw() in JPEG/DCT decoder.
Suppose an application that uses MuPDF implements its own
allocator that limits the amount of memory that may be allocated.
When that condition occurs fz_malloc() will throw an exception,
this exception would then be thrown right back to MuPDF without
allowing for libjpeg to free any of the memory it has allocated.
After this commit fz_malloc_no_throw() is called, which under the
same conditions would simply return NULL. allowing for libjpeg to
free what ever allocations it has done, and return to MuPDF with
an error just like before.
Diffstat (limited to 'source/fitz')
-rw-r--r-- | source/fitz/filter-dct.c | 2 | ||||
-rw-r--r-- | source/fitz/load-jpeg.c | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/source/fitz/filter-dct.c b/source/fitz/filter-dct.c index a3ada67e..c3654cf8 100644 --- a/source/fitz/filter-dct.c +++ b/source/fitz/filter-dct.c @@ -46,7 +46,7 @@ static void * fz_dct_mem_alloc(j_common_ptr cinfo, size_t size) { fz_dctd *state = JZ_DCT_STATE_FROM_CINFO(cinfo); - return fz_malloc(state->ctx, size); + return fz_malloc_no_throw(state->ctx, size); } static void diff --git a/source/fitz/load-jpeg.c b/source/fitz/load-jpeg.c index 87b32431..3db94a6b 100644 --- a/source/fitz/load-jpeg.c +++ b/source/fitz/load-jpeg.c @@ -24,7 +24,7 @@ static void * fz_jpg_mem_alloc(j_common_ptr cinfo, size_t size) { fz_context *ctx = JZ_CTX_FROM_CINFO(cinfo); - return fz_malloc(ctx, size); + return fz_malloc_no_throw(ctx, size); } static void |