index 6c48d67..819158b 100644 (file)
@@ -24,6 +24,9 @@
 /*Header Definitions*/
 #include "fits2jpeg.h"
 
+/*---------------------------------------------------------------------------*
+ * READ_FITS: To reads data from a fits image file.. (isn't that obvious?)
+ *---------------------------------------------------------------------------*/
 void read_fits(char * fits_file_name, long * xdim, long * ydim, float ** data)
 {
     fitsfile *fptr;
@@ -79,6 +82,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;