Index: trunk/psphot/src/psphotChoosePSF.c
===================================================================
--- trunk/psphot/src/psphotChoosePSF.c	(revision 20286)
+++ trunk/psphot/src/psphotChoosePSF.c	(revision 20287)
@@ -9,6 +9,6 @@
         pmSource *source = sources->data[i];
         if (source->mode & PM_SOURCE_MODE_PSFSTAR) {
-	    nPSF ++;
-	}
+            nPSF ++;
+        }
     }
 
@@ -289,5 +289,5 @@
     // XXX test dump of psf star data and psf-subtracted image
     if (psTraceGetLevel("psphot.psfstars") > 5) {
-	psphotDumpPSFStars (readout, try, options->radius, maskVal, markVal);
+        psphotDumpPSFStars (readout, try, options->radius, maskVal, markVal);
     }
 
@@ -333,29 +333,29 @@
 
     for (float ix = -0.4; ix <= +0.4; ix += 0.1) {
-	for (float iy = -0.4; iy <= +0.4; iy += 0.1) {
-
-	    // use the center of the center pixel of the image
-	    float xc = ix*image->numCols + 0.5*image->numCols + image->col0 + 0.5;
-	    float yc = iy*image->numRows + 0.5*image->numRows + image->row0 + 0.5;
-
-	    // create modelPSF from this model
-	    pmModel *modelPSF = pmModelFromPSFforXY (psf, xc, yc, 1.0);
-	    if (!modelPSF) continue;
-
-	    // get the model full-width at half-max
-	    float FWHM_MAJOR = 2*modelPSF->modelRadius (modelPSF->params, 0.5);
-
-	    // XXX make sure this is consistent with the re-definition of PM_PAR_SXX
-	    shape.sx  = modelPSF->params->data.F32[PM_PAR_SXX];
-	    shape.sy  = modelPSF->params->data.F32[PM_PAR_SYY];
-	    shape.sxy = modelPSF->params->data.F32[PM_PAR_SXY];
-	    axes = psEllipseShapeToAxes (shape, 20.0);
-	    psFree (modelPSF);
-
-	    float FWHM_MINOR = FWHM_MAJOR * (axes.minor / axes.major);
-	    if (!isfinite(FWHM_MAJOR) || !isfinite(FWHM_MINOR)) continue;
-	    psVectorAppend (fwhmMajor, FWHM_MAJOR);
-	    psVectorAppend (fwhmMinor, FWHM_MINOR);
-	}
+        for (float iy = -0.4; iy <= +0.4; iy += 0.1) {
+
+            // use the center of the center pixel of the image
+            float xc = ix*image->numCols + 0.5*image->numCols + image->col0 + 0.5;
+            float yc = iy*image->numRows + 0.5*image->numRows + image->row0 + 0.5;
+
+            // create modelPSF from this model
+            pmModel *modelPSF = pmModelFromPSFforXY (psf, xc, yc, 1.0);
+            if (!modelPSF) continue;
+
+            // get the model full-width at half-max
+            float FWHM_MAJOR = 2*modelPSF->modelRadius (modelPSF->params, 0.5);
+
+            // XXX make sure this is consistent with the re-definition of PM_PAR_SXX
+            shape.sx  = modelPSF->params->data.F32[PM_PAR_SXX];
+            shape.sy  = modelPSF->params->data.F32[PM_PAR_SYY];
+            shape.sxy = modelPSF->params->data.F32[PM_PAR_SXY];
+            axes = psEllipseShapeToAxes (shape, 20.0);
+            psFree (modelPSF);
+
+            float FWHM_MINOR = FWHM_MAJOR * (axes.minor / axes.major);
+            if (!isfinite(FWHM_MAJOR) || !isfinite(FWHM_MINOR)) continue;
+            psVectorAppend (fwhmMajor, FWHM_MAJOR);
+            psVectorAppend (fwhmMinor, FWHM_MINOR);
+        }
     }
 
@@ -405,4 +405,7 @@
         if (!source) continue;
         if (!(source->mode & PM_SOURCE_MODE_PSFSTAR)) continue;
+        if (!source->moments) {
+            continue;
+        }
 
         moments.x2 = source->moments->Mxx;
