Index: trunk/psLib/src/fits/psFitsImage.c
===================================================================
--- trunk/psLib/src/fits/psFitsImage.c	(revision 18208)
+++ trunk/psLib/src/fits/psFitsImage.c	(revision 18392)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2008-06-20 02:50:01 $
+ *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2008-07-01 04:26:26 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -522,4 +522,5 @@
     int numRows = image->numRows;       // Number of rows for image
     int status = 0;                     // Status from cfitsio
+    bool success = true;
     psFitsCompression *compress = NULL; // FITS compression parameters; to save state
 
@@ -531,5 +532,6 @@
     if (!diskImage) {
         psError(PS_ERR_UNKNOWN, false, "Unable to convert image to desired disk format.");
-        goto INSERT_FAIL;
+        success = false;
+        goto INSERT_DONE;
     }
 
@@ -537,9 +539,10 @@
     if (!isfinite(bscale) || !isfinite(bzero)) {
         // Couldn't scale, so don't compress.  Save compression parameters for later
-	useRequestedScale = false;
+        useRequestedScale = false;
         compress = psFitsCompressionGet(fits);
         if (!psFitsSetCompression(fits, PS_FITS_COMPRESS_NONE, NULL, 0, 0, 0)) {
             psError(PS_ERR_IO, false, "Unable to unset compression.");
-            goto INSERT_FAIL;
+            success = false;
+            goto INSERT_DONE;
         }
     }
@@ -550,5 +553,6 @@
     int dataType;                       // cfitsio data type
     if (!p_psFitsTypeToCfitsio(diskImage->type.type, &bitPix, &cfitsioBzero, &dataType)) {
-        goto INSERT_FAIL;
+        success = false;
+        goto INSERT_DONE;
     }
     if (cfitsioBzero != 0.0) {
@@ -592,5 +596,6 @@
     }
     if (psFitsError(status, true, "Could not create image HDU.")) {
-        goto INSERT_FAIL;
+        success = false;
+        goto INSERT_DONE;
     }
 
@@ -598,5 +603,6 @@
     if (header && !psFitsWriteHeader(fits, header)) {
         psError(PS_ERR_IO, false, "Unable to write FITS header.\n");
-        goto INSERT_FAIL;
+        success = false;
+        goto INSERT_DONE;
     }
 
@@ -612,5 +618,6 @@
                            "Scaling: TRUE = BZERO + BSCALE * DISK", &status);
         if (psFitsError(status, true, "Could not write BSCALE/BZERO headers to file.")) {
-            goto INSERT_FAIL;
+            success = false;
+            goto INSERT_DONE;
         }
     }
@@ -624,5 +631,6 @@
         fits_set_imgnull(fits->fd, blank, &status);
         if (psFitsError(status, true, "Could not write BLANK header to file.")) {
-            goto INSERT_FAIL;
+            success = false;
+            goto INSERT_DONE;
         }
     }
@@ -648,10 +656,9 @@
     }
     if (psFitsError(status, true, "Could not write image to file.")) {
-        goto INSERT_FAIL;
-    }
-
-    return true;
-
-INSERT_FAIL:
+        success = false;
+        goto INSERT_DONE;
+    }
+
+ INSERT_DONE:
     psFree(diskImage);
     if (compress) {
@@ -660,5 +667,5 @@
         psFree(compress);
     }
-    return false;
+    return success;
 }
 
@@ -699,5 +706,5 @@
     if (!isfinite(bscale) || !isfinite(bzero)) {
         // Couldn't scale, so don't compress.  Save compression parameters for later
-	useRequestedScale = false;
+        useRequestedScale = false;
         compress = psFitsCompressionGet(fits);
         if (!psFitsSetCompression(fits, PS_FITS_COMPRESS_NONE, NULL, 0, 0, 0)) {
