Index: trunk/psphot/src/psphotSourceStats.c
===================================================================
--- trunk/psphot/src/psphotSourceStats.c	(revision 32633)
+++ trunk/psphot/src/psphotSourceStats.c	(revision 32699)
@@ -101,10 +101,8 @@
 
     // generate the array of sources, define the associated pixel
-    bool firstPass = false;
-    if (!detections->newSources) {
-        detections->newSources = psArrayAllocEmpty (peaks->n);
-	firstPass = true;
-    }
-    sources = detections->newSources;
+    psAssert (!detections->newSources, "programming error");
+    sources = detections->newSources = psArrayAllocEmpty (peaks->n);
+
+    bool firstPass = (detections->allSources == NULL);
 
     // if there are no peaks, we save the empty source array and return
