Index: trunk/psModules/src/objects/pmSource.c
===================================================================
--- trunk/psModules/src/objects/pmSource.c	(revision 11687)
+++ trunk/psModules/src/objects/pmSource.c	(revision 11762)
@@ -6,6 +6,6 @@
  *  @author EAM, IfA: significant modifications.
  *
- *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-01-24 21:32:19 $
+ *  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-02-13 03:14:42 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -292,5 +292,10 @@
         // find the peak in this image
         stats = psStatsAlloc (PS_STAT_MAX);
-        stats = psImageStats (stats, splane, NULL, 0);
+        if (!psImageStats (stats, splane, NULL, 0)) {
+            psError(PS_ERR_UNKNOWN, false, "Unable to get image statistics.\n");
+            psFree(stats);
+            psFree(splane);
+            return emptyClump;
+        }
         peaks = pmFindImagePeaks (splane, stats[0].max / 2);
         psTrace ("psModules.objects", 2, "clump threshold is %f\n", stats[0].max/2);
@@ -544,5 +549,5 @@
 pmSource data structure, along with the peak location, and determines the
 various moments associated with that peak.
- 
+
 Requires the following to have been created:
     pmSource
@@ -551,7 +556,7 @@
     pmSource->weight
     pmSource->mask
- 
+
 XXX: The peak calculations are done in image coords, not subImage coords.
- 
+
 XXX EAM : this version clips input pixels on S/N
 XXX EAM : this version returns false for several reasons
Index: trunk/psModules/src/objects/pmSourceSky.c
===================================================================
--- trunk/psModules/src/objects/pmSourceSky.c	(revision 11687)
+++ trunk/psModules/src/objects/pmSourceSky.c	(revision 11762)
@@ -6,6 +6,6 @@
  *  @author EAM, IfA: significant modifications.
  *
- *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-10-17 02:21:03 $
+ *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-02-13 03:14:42 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -33,8 +33,8 @@
 pmSource *pmSourceLocalSky(source, statsOptions, Radius): this
 routine creates a new pmSource.moments element if needed and sets pmSource.pmMoments.sky
- 
+
 The sky value is set from the pixels in the square annulus surrounding the
 peak pixel.
- 
+
 The source.pixels and source.mask must already exist
 *****************************************************************************/
@@ -69,5 +69,9 @@
     psImageMaskRegion(mask, srcRegion, "OR", PM_MASK_MARK);
     psStats *myStats = psStatsAlloc(statsOptions);
-    myStats = psImageStats(myStats, image, mask, 0xff);
+    if (!psImageStats(myStats, image, mask, 0xff)) {
+        psError(PS_ERR_UNKNOWN, false, "Unable to get image statistics.\n");
+        psFree(myStats);
+        return false;
+    }
     psImageMaskRegion(mask, srcRegion, "AND", PS_NOT_U8(PM_MASK_MARK));
     double value = psStatsGetValue(myStats, statistic);
@@ -116,5 +120,9 @@
     psImageMaskRegion(mask, srcRegion, "OR", PM_MASK_MARK);
     psStats *myStats = psStatsAlloc(statsOptions);
-    myStats = psImageStats(myStats, image, mask, 0xff);
+    if (!psImageStats(myStats, image, mask, 0xff)) {
+        psError(PS_ERR_UNKNOWN, false, "Unable to get image statistics.\n");
+        psFree(myStats);
+        return false;
+    }
     psImageMaskRegion(mask, srcRegion, "AND", PS_NOT_U8(PM_MASK_MARK));
     double value = psStatsGetValue(myStats, statistic);
