Index: /branches/eam_branches/ipp-20100823/psLib/src/math/psMinimizeLMM.c
===================================================================
--- /branches/eam_branches/ipp-20100823/psLib/src/math/psMinimizeLMM.c	(revision 29341)
+++ /branches/eam_branches/ipp-20100823/psLib/src/math/psMinimizeLMM.c	(revision 29342)
@@ -325,7 +325,7 @@
         chisq += PS_SQR(delta) * dy->data.F32[i];
 
-        if (isnan(dy->data.F32[i])) return NAN;
-        if (isnan(delta)) return NAN;
-        if (isnan(chisq)) return NAN;
+        if (isnan(dy->data.F32[i])) goto escape;
+        if (isnan(delta)) goto escape;
+        if (isnan(chisq)) goto escape;
 
         // we track alpha,beta and params,deriv separately
@@ -354,4 +354,8 @@
     psFree(deriv);
     return(chisq);
+
+escape:
+    psFree(deriv);
+    return NAN;
 }
 
@@ -448,4 +452,9 @@
     if (isnan(min->value)) {
         min->iter = min->maxIter;
+	psFree(alpha);
+	psFree(Alpha);
+	psFree(beta);
+	psFree(Beta);
+	psFree(Params);
         return(false);
     }
Index: /branches/eam_branches/ipp-20100823/psphot/src/psphotSourceFits.c
===================================================================
--- /branches/eam_branches/ipp-20100823/psphot/src/psphotSourceFits.c	(revision 29341)
+++ /branches/eam_branches/ipp-20100823/psphot/src/psphotSourceFits.c	(revision 29342)
@@ -551,4 +551,5 @@
 
     	if (!psphotFitSersicIndexPCM (pcm, readout, source, fitOptions, maskVal, markVal, psfSize)) {
+	    psFree (pcm);
 	    model->flags |= PM_MODEL_STATUS_BADARGS;
 	    return model;
