From: Rekhesh Mohan Date: Mon, 22 Oct 2012 13:49:38 +0000 (+0530) Subject: fixed a segfault on '0' images X-Git-Url: https://cads.iiap.res.in/gitview/?p=fits2jpeg.git;a=commitdiff_plain;h=79b85977067a1c29cb89a366516dd15546f15eee fixed a segfault on '0' images --- diff --git a/configure.ac b/configure.ac index ef21fc7..7c67dd6 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([CADS_fits2jpeg], [1.99], [cads@iiap.res.in]) +AC_INIT([CADS_fits2jpeg], [2.0.9], [cads@iiap.res.in]) AC_LANG_C AM_INIT_AUTOMAKE([-Wall -Werror]) AC_CONFIG_SRCDIR([config.h.in]) diff --git a/src/image.c b/src/image.c index 6c48d67..7f7a8e8 100644 --- a/src/image.c +++ b/src/image.c @@ -79,6 +79,9 @@ void scale_pixels(int scale, unsigned int npixels, float *data, /* the dynamic range is reduced to 255 for jpeg */ scl_data = (datamax - datamin)/(float)JMAXVAL; + /* we will end up with segfaults if scl_data = 0 */ + if (scl_data = 0) scl_data = 1; + for (i = 0; i < npixels; ++i) data[i] = (data[i] - datamin)/scl_data;