Index: trunk/psphot/src/psphotChoosePSF.c
===================================================================
--- trunk/psphot/src/psphotChoosePSF.c	(revision 13225)
+++ trunk/psphot/src/psphotChoosePSF.c	(revision 13429)
@@ -196,4 +196,5 @@
     if (!psphotMakeResiduals (try->sources, recipe, try->psf)) {
 	psError(PSPHOT_ERR_PSF, false, "Unable to construct residual table for PSF");
+	psFree (models);
 	return NULL;
     }
@@ -244,5 +245,6 @@
 
 	    psEllipseAxes axes1 = psEllipseShapeToAxes (shape, 20.0);
-	    psEllipseAxes axes2 = psEllipsePolToAxes (pol, 0.1);
+	    psEllipseAxes axes2;
+	    (void)psEllipsePolToAxes(pol, 0.1, &axes2);
 	    psEllipsePol pol2 = psEllipseAxesToPol (axes1);
 
@@ -275,5 +277,9 @@
     psFree (models);
 
-    if (!psphotPSFstats (readout, recipe, psf)) psAbort("cannot measure PSF shape terms");
+    if (!psphotPSFstats (readout, recipe, psf)) {
+	psError(PSPHOT_ERR_PSF, false, "cannot measure PSF shape terms");
+	psFree(psf);
+	return NULL;
+    }
 
     modelName = pmModelGetType (psf->type);
@@ -308,5 +314,9 @@
     // construct a PSF model at this coordinate
     pmModel *modelPSF = pmModelFromPSF (modelEXT, psf);
-    PS_ASSERT_PTR_NON_NULL(modelPSF, false);
+    if (modelPSF == NULL) {
+	psError(PSPHOT_ERR_PSF, false, "Failed to estimate PSF model at image centre");
+	psFree(modelEXT);
+	return false;
+    }
 
     // get the correct model-radius function
