Index: trunk/psModules/src/objects/pmPSFtryModel.c
===================================================================
--- trunk/psModules/src/objects/pmPSFtryModel.c	(revision 26260)
+++ trunk/psModules/src/objects/pmPSFtryModel.c	(revision 27330)
@@ -78,6 +78,6 @@
     }
 
-    // this is a bit tricky, because we have two cases (MAP vs POLY), and they have a different 
-    // definition for 'order' (order_MAP = order_POLY + 1).  in addition, we have a 
+    // this is a bit tricky, because we have two cases (MAP vs POLY), and they have a different
+    // definition for 'order' (order_MAP = order_POLY + 1).  in addition, we have a
     // user-specified MAX order, which we should respect, regardless of the mode
 
@@ -93,6 +93,6 @@
     int orderMin = 0;
     if (options->psfTrendMode == PM_TREND_MAP) {
-	MaxOrderForStars ++;
-	orderMin ++;
+        MaxOrderForStars ++;
+        orderMin ++;
     }
     orderMax = PS_MIN (orderMax, MaxOrderForStars);
@@ -204,14 +204,17 @@
                   psStatsGetValue(stats, meanStat), psStatsGetValue(stats, stdevStat));
 
-        psFree(flux);
-        psFree(mask);
-        psFree(chisq);
-
         if (!result) {
             psError(PS_ERR_UNKNOWN, false, "Failed to fit psf->ChiTrend");
             psFree(psfTry);
-            return NULL;
-        }
-    }
+            psFree(flux);
+            psFree(mask);
+            psFree(chisq);
+            return NULL;
+        }
+    }
+
+    psFree(flux);
+    psFree(mask);
+    psFree(chisq);
 
     for (int i = 0; i < psfTry->psf->ChiTrend->nX + 1; i++) {
