Index: trunk/psLib/src/fits/psFitsImage.c
===================================================================
--- trunk/psLib/src/fits/psFitsImage.c	(revision 18580)
+++ trunk/psLib/src/fits/psFitsImage.c	(revision 18590)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.35 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2008-07-16 23:05:06 $
+ *  @version $Revision: 1.36 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2008-07-17 03:34:22 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -703,4 +703,5 @@
     psFitsCompression *compress = NULL; // FITS compression parameters; to save state
 
+    bool success = true;                // Successful update?
     double bscale = NAN, bzero = NAN;   // Scale and zero point to put in header
     long blank = 0;                     // Blank (undefined) value for image
@@ -710,5 +711,6 @@
     if (!diskImage) {
         psError(PS_ERR_UNKNOWN, false, "Unable to convert image to desired disk format.");
-        goto UPDATE_FAIL;
+        success = false;
+        goto UPDATE_DONE;
     }
 
@@ -720,5 +722,6 @@
         if (!psFitsSetCompression(fits, PS_FITS_COMPRESS_NONE, NULL, 0, 0, 0)) {
             psError(PS_ERR_IO, false, "Unable to unset compression.");
-            goto UPDATE_FAIL;
+            success = false;
+            goto UPDATE_DONE;
         }
     }
@@ -729,5 +732,6 @@
     int dataType;                       // cfitsio data type
     if (!p_psFitsTypeToCfitsio(diskImage->type.type, &bitPix, &cfitsioBzero, &dataType)) {
-        goto UPDATE_FAIL;
+        success = false;
+        goto UPDATE_DONE;
     }
     if (cfitsioBzero != 0.0) {
@@ -751,5 +755,6 @@
         psError(PS_ERR_BAD_PARAMETER_SIZE, true,
                 _("Current FITS HDU has %ld z-planes, but z-plane %d was specified."), nAxes[2], z);
-        goto UPDATE_FAIL;
+        success = false;
+        goto UPDATE_DONE;
     }
 
@@ -773,5 +778,6 @@
                 "Input image [size of %ix%i] at position (%i,%i) does not all lay in the %lix%li FITS image.",
                 numCols, numRows, x0, y0, nAxes[0], nAxes[1]);
-        goto UPDATE_FAIL;
+        success = false;
+        goto UPDATE_DONE;
     }
 
@@ -782,5 +788,6 @@
     fits_write_subset(fits->fd, dataType, firstPixel, lastPixel, diskImage->data.V[0], &status);
     if (psFitsError(status, true, "Could not write data to file.")) {
-        goto UPDATE_FAIL;
+        success = false;
+        goto UPDATE_DONE;
     }
 
@@ -790,11 +797,9 @@
     ffrdef(fits->fd, &status);
     if (psFitsError(status, true, "Could not re-scan HDU.")) {
-        goto UPDATE_FAIL;
-    }
-
-    psFree(diskImage);
-    return true;
-
-UPDATE_FAIL:
+        success = false;
+        goto UPDATE_DONE;
+    }
+
+UPDATE_DONE:
     psFree(diskImage);
     if (compress) {
@@ -803,5 +808,6 @@
         psFree(compress);
     }
-    return false;
+
+    return success;
 }
 
