Index: trunk/psphot/src/source_moments.c
===================================================================
--- trunk/psphot/src/source_moments.c	(revision 4574)
+++ trunk/psphot/src/source_moments.c	(revision 4901)
@@ -5,4 +5,6 @@
     bool     status  = false;
     psArray *sources = NULL;
+
+    psMemoryId id = psMemGetId ();
 
     psTimerStart ("psphot");
@@ -17,19 +19,28 @@
 
     for (int i = 0; i < peaks->n; i++) {
+
 	// create a new source, add peak
 	psSource *source = pmSourceAlloc();
-	source->peak = (psPeak *)peaks->data[i];
+	source->peak = (psPeak *)psMemCopy(peaks->data[i]);
 
 	// allocate image, noise, mask arrays for each peak (square of radius OUTER)
+	// XXX - this has 12 leaks (v.5)
 	pmSourceDefinePixels (source, imdata, source->peak->x, source->peak->y, OUTER);
 
 	// this should use ROBUST not SAMPLE median, but it is broken
 	status = pmSourceLocalSky_EAM (source, PS_STAT_SAMPLE_MEDIAN, INNER);
-	if (!status) continue;
+	if (!status) {
+	  psFree (source);
+	  continue;
+	}
 
 	status = pmSourceMoments (source, RADIUS);
-	if (!status) continue;
+	if (!status) {
+	  psFree (source);
+	  continue;
+	}
 	
 	psArrayAdd (sources, 100, source);
+	psFree (source);
     }
 
