Index: trunk/psphot/src/psphotFindDetections.c
===================================================================
--- trunk/psphot/src/psphotFindDetections.c	(revision 20171)
+++ trunk/psphot/src/psphotFindDetections.c	(revision 20177)
@@ -20,17 +20,17 @@
     // on first pass, detections have not yet been allocated
     if (!detections) {
-	detections = pmDetectionsAlloc();
-	pass = 1;
+        detections = pmDetectionsAlloc();
+        pass = 1;
         NSIGMA_PEAK = psMetadataLookupF32 (&status, recipe, "PEAKS_NSIGMA_LIMIT"); PS_ASSERT (status, NULL);
         NMAX = psMetadataLookupS32 (&status, recipe, "PEAKS_NMAX"); PS_ASSERT (status, NULL);
     } else {
-	pass = 2;
+        pass = 2;
         NSIGMA_PEAK = psMetadataLookupF32 (&status, recipe, "PEAKS_NSIGMA_LIMIT_2"); PS_ASSERT (status, NULL);
-	NMAX = 0; // unlimited number of peaks in final pass: allow a limit (PEAKS_NMAX_2) ?
+        NMAX = 0; // unlimited number of peaks in final pass: allow a limit (PEAKS_NMAX_2) ?
     }
 
     float threshold = PS_SQR(NSIGMA_PEAK);
 
-    // move the old peaks array (if it exists) to oldPeaks 
+    // move the old peaks array (if it exists) to oldPeaks
     // XXX generically, we should be able to call this function an arbitrary number of times
     assert (detections->oldPeaks == NULL);
@@ -47,8 +47,12 @@
     detections->peaks = psphotFindPeaks (significance, readout, recipe, threshold, NMAX);
     psMetadataAddF32  (recipe, PS_LIST_TAIL, "PEAK_THRESHOLD", PS_META_REPLACE, "Peak Detection Threshold", threshold);
+    if (!detections->peaks) {
+        // No peaks found
+        return NULL;
+    }
 
     // optionally merge peaks into footprints
     if (useFootprints) {
-	psphotFindFootprints (detections, significance, readout, recipe, pass, maskVal);
+        psphotFindFootprints (detections, significance, readout, recipe, pass, maskVal);
     }
 
