Index: /trunk/psphot/src/psphotReadoutCleanup.c
===================================================================
--- /trunk/psphot/src/psphotReadoutCleanup.c	(revision 13834)
+++ /trunk/psphot/src/psphotReadoutCleanup.c	(revision 13835)
@@ -20,5 +20,9 @@
 	psErrorClear();
     } 
-    if (psErrorCodeLast() != PS_ERR_NONE) return false;
+    if (psErrorCodeLast() != PS_ERR_NONE) { 
+	psFree (psf);
+	psFree (sources);
+	return false;
+    }
 
     // use the psf-model to measure FWHM stats
@@ -26,4 +30,6 @@
         if (!psphotPSFstats (readout, recipe, psf)) {
             psError(PSPHOT_ERR_PROG, false, "Failed to measure PSF shape parameters");
+	    psFree (psf);
+	    psFree (sources);
             return false;
         }
@@ -33,4 +39,5 @@
         if (!psphotMomentsStats (readout, recipe, sources)) {
             psError(PSPHOT_ERR_PROG, false, "Failed to measure Moment shape parameters");
+	    psFree (sources);
             return false;
         }
@@ -59,5 +66,5 @@
     }
 
-    // XXX move this to top of loop
+    // XXX move this to top of loop?
     pmKapaClose ();
 
