diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2023-09-28 02:40:42 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2023-09-28 02:40:42 +0000 |
commit | 34546ecb9b586f34e04f6e133a247ffe1f50046e (patch) | |
tree | 55c0c6c76c55bfe99a9f3c7dec416604a1c6dbd9 /converter/other/jpegtopnm.c | |
parent | d484f36f7c690d0a88476127afd9bdf90233699d (diff) | |
download | netpbm-mirror-34546ecb9b586f34e04f6e133a247ffe1f50046e.tar.gz netpbm-mirror-34546ecb9b586f34e04f6e133a247ffe1f50046e.tar.xz netpbm-mirror-34546ecb9b586f34e04f6e133a247ffe1f50046e.zip |
Release 1.04.00
git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@4700 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter/other/jpegtopnm.c')
-rw-r--r-- | converter/other/jpegtopnm.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/converter/other/jpegtopnm.c b/converter/other/jpegtopnm.c index 7d1750a7..518d80ac 100644 --- a/converter/other/jpegtopnm.c +++ b/converter/other/jpegtopnm.c @@ -827,11 +827,17 @@ convertRaster(struct jpeg_decompress_struct * const cinfoP, xel * pnmbuffer; /* Output buffer */ - jpegbuffer = ((*cinfoP->mem->alloc_sarray) - ((j_common_ptr) cinfoP, JPOOL_IMAGE, - cinfoP->output_width * cinfoP->output_components, - (JDIMENSION) 1) - )[0]; + if (cinfoP->output_width > UINT_MAX/cinfoP->output_components) + pm_error("Image is too wide (%u columns) for computations", + cinfoP->output_width); + + MALLOCARRAY(jpegbuffer, + cinfoP->output_width * cinfoP->output_components); + + if (!jpegbuffer) + pm_error("Failed to allocated a buffer for a row of %u columns " + "of %u samples each", + cinfoP->output_width, cinfoP->output_components); pnmbuffer = pnm_allocrow(cinfoP->output_width); @@ -846,6 +852,8 @@ convertRaster(struct jpeg_decompress_struct * const cinfoP, maxval, format, false); } } + + free(jpegbuffer); pnm_freerow(pnmbuffer); } |