Index: trunk/psModules/src/objects/pmSourcePhotometry.c
===================================================================
--- trunk/psModules/src/objects/pmSourcePhotometry.c	(revision 17997)
+++ trunk/psModules/src/objects/pmSourcePhotometry.c	(revision 17998)
@@ -3,6 +3,6 @@
  *  @author EAM, IfA; GLG, MHPCC
  *
- *  @version $Revision: 1.41 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2008-04-08 18:35:38 $
+ *  @version $Revision: 1.42 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2008-06-09 00:43:46 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -246,21 +246,16 @@
     if (!status) {
         psTrace ("psModules.objects", 3, "fail mag : bad Ap Mag");
-        psErrorCode last = psErrorCodeLast();
-        // XXX flag the object?
-        if (last == PM_ERR_PHOTOM) {
-            // the aper mag was undefined (flux < 0).  bad object, but
-            // don't keep the error on the stack
-            psErrorClear();
-        }
     }
 
     // for PSFs, correct both apMag and psfMag to same system, consistent with infinite flux star in aperture RADIUS
-    if (status && isPSF && psf) {
+    // if the aper mag is NAN, the flux < 0.  this can happen for sources near the
+    // detection limits (esp near bright neighbors)
+    if (isfinite (source->apMag) && isPSF && psf) {
         if (psf->growth && (mode & PM_SOURCE_PHOT_GROWTH)) {
             source->apMag += pmGrowthCurveCorrect (psf->growth, model->radiusFit);
         }
         if (mode & PM_SOURCE_PHOT_APCORR) {
-            rflux   = pow (10.0, 0.4*source->psfMag);
-            source->apMag  -= PS_SQR(model->radiusFit)*rflux * psf->skyBias + psf->skySat / rflux;
+	    rflux   = pow (10.0, 0.4*source->psfMag);
+	    source->apMag -= PS_SQR(model->radiusFit)*rflux * psf->skyBias + psf->skySat / rflux;
         }
     }
@@ -343,10 +338,10 @@
     }
     if (apSum <= 0) {
-	psError(PM_ERR_PHOTOM, true, "apSum is negative");
-        return false;
+	*apMag = NAN;
+        return true;
     }
 
     *apMag = -2.5*log10(apSum);
-    return (true);
+    return true;
 }
 
