Index: trunk/psModules/src/astrom/pmAstrometryObjects.c
===================================================================
--- trunk/psModules/src/astrom/pmAstrometryObjects.c	(revision 11754)
+++ trunk/psModules/src/astrom/pmAstrometryObjects.c	(revision 11762)
@@ -8,6 +8,6 @@
 *  @author EAM, IfA
 *
-*  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2007-02-07 01:31:40 $
+*  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2007-02-13 03:14:42 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -36,5 +36,5 @@
 /******************************************************************************
 pmAstromObjSortByMag(**a, **b): sort by mag (descending)
- 
+
 Is this a private routine?
 Should we do the early asserts?
@@ -454,5 +454,5 @@
 AstromGridBin(*dx, *dy, dX, dY): local function to convert x,y coords to grid
 bins it requires the globals defined above.
- 
+
  ******************************************************************************/
 static bool AstromGridBin(
@@ -567,5 +567,14 @@
         // find the max pixel
         psStats *imStats = psStatsAlloc (PS_STAT_MAX | PS_STAT_MAX | PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_STDEV);
-        imStats = psImageStats (imStats, gridNP, NULL, 0);
+        if (!psImageStats(imStats, gridNP, NULL, 0)) {
+            psError(PS_ERR_UNKNOWN, false, "Unable to get image statistics.\n");
+            psFree(imStats);
+            psFree(gridNP);
+            psFree(gridDX);
+            psFree(gridDY);
+            psFree(gridD2);
+            psFree(stats);
+            return NULL;
+        }
 
         # if 0
@@ -860,5 +869,5 @@
    +15:+25 -> 5
    +25:+35 -> 6
- 
+
    maxOffsetRequest = 30
    nPix = (int) (maxOffset / dPix + 0.5);
Index: trunk/psModules/src/objects/pmSource.c
===================================================================
--- trunk/psModules/src/objects/pmSource.c	(revision 11754)
+++ 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 11754)
+++ 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);
