From 79b85977067a1c29cb89a366516dd15546f15eee Mon Sep 17 00:00:00 2001 From: Rekhesh Mohan Date: Mon, 22 Oct 2012 19:19:38 +0530 Subject: [PATCH] fixed a segfault on '0' images --- configure.ac | 2 +- src/image.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) 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; -- 2.12.1