From 5eb3dae7f140abe00f15e5eebdf17eddbf8bb64f Mon Sep 17 00:00:00 2001 From: Shank Date: Wed, 14 Dec 2022 19:01:49 -0500 Subject: [PATCH] check return value jpeg_read_coefficients to prevent NULL-ptr dereference --- quantsmooth.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/quantsmooth.c b/quantsmooth.c index e9cf8f9..d1d7b7e 100644 --- a/quantsmooth.c +++ b/quantsmooth.c @@ -528,6 +528,10 @@ int main(int argc, char **argv) { (void) jpeg_read_header(&srcinfo, TRUE); coef_arrays = jpeg_read_coefficients(&srcinfo); + if (coef_arrays == NULL) { + logfmt(LS ": can't read coefficients\n", progname); + return 1; + } do_quantsmooth(&srcinfo, coef_arrays, &opts); jpeg_copy_critical_parameters(&srcinfo, &dstinfo);