authorRekhesh Mohan <reks@iiap.res.in>
Thu, 8 Nov 2012 08:10:53 +0000 (13:40 +0530)
committerRekhesh Mohan <reks@iiap.res.in>
Thu, 8 Nov 2012 08:10:53 +0000 (13:40 +0530)
Conflicts:
ChangeLog.txt
configure.ac
src/filesys.c
src/fits2jpeg.c
src/image.c

.gitignore
ChangeLog.txt
configure.ac
src/filesys.c
src/fits2jpeg.c
src/getopt.c
src/image.c

index 3820d63..40495b4 100644 (file)
@@ -16,5 +16,6 @@ src/*.o
 stamp-h1
 *~
 .*.swp
+.*swp
 *.bak
 *.lock
index e10220c..353882a 100644 (file)
@@ -6,10 +6,14 @@ NOTE: This file records the changes made after the release of the stable
 version fits2jpeg-1.0
 ------------------------------------------------------------------------
 
+2.1 Release
+-----------
 
+  1. Fixed a segfault on blank/zero images
 
-Updates in 2.0 Release
-----------------------
+
+2.0 Release
+-----------
 
   1. Merged scale & operations to single flag
      v1.0 had normalize/equalize handled by "-e" flag and rest of
index 0e27801..303f90a 100644 (file)
@@ -1,4 +1,4 @@
-AC_INIT([CADS_fits2jpeg], [2.0], [cads@iiap.res.in])
+AC_INIT([CADS_fits2jpeg], [2.1], [cads@iiap.res.in])
 AC_LANG_C
 AM_INIT_AUTOMAKE([-Wall -Werror])
 AC_CONFIG_SRCDIR([config.h.in])
index e7ff547..8e40c52 100644 (file)
@@ -23,7 +23,6 @@
 
 /*Header Definitions*/
 #include "fits2jpeg.h"
-/*---------------------------------------------------------------------------*/
 
 /*---------------------------------------------------------------------------*
  * MAKE_DIR: Wrapper to mkdir() with some basic error checks
index 7390330..5469733 100644 (file)
@@ -71,7 +71,7 @@
   Reks 28 June 2012
   1. rebranded to CADS/UVS
 
-  Reks 05-10 July 2012 v2.0 plans
+  Reks 05-10 July 2012 v2.0 
   1. Merged scale & operations to single flag
   2. added fits2jpeg.h, help/banner functions moved to messages.c
   3. Options to clip image min/max
@@ -81,6 +81,9 @@
   7. Image resizing
   8. moved fits read to image.c
   9. Option to specify output directory
+
+  Reks Oct/Nov 2012 v2.1
+  1. Fixed a segfault on zero/blank fits images
  *---------------------------------------------------------------------------*/
 
 #include "fits2jpeg.h"
index 5f27eb8..2e76f34 100644 (file)
@@ -109,7 +109,7 @@ int my_getopt(int nargc, char * const *nargv, const char *ostr)
                 (void)fprintf(stderr,
                               "ERROR  : option requires an argument -- %c\n",
                               optopt);
-            return (BADCH);
+            exit (BADCH);
         }
         else                                                   /* white space */
             optarg = nargv[optindex];
index a47b9b7..819158b 100644 (file)
@@ -82,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;