Index: trunk/psModules/src/objects/pmSource.c
===================================================================
--- trunk/psModules/src/objects/pmSource.c	(revision 15979)
+++ trunk/psModules/src/objects/pmSource.c	(revision 15980)
@@ -6,6 +6,6 @@
  *  @author EAM, IfA: significant modifications.
  *
- *  @version $Revision: 1.47 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-12-13 22:09:35 $
+ *  @version $Revision: 1.48 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2008-01-02 20:39:04 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -130,9 +130,4 @@
 }
 
-bool pmSourceTest(const psPtr ptr)
-{
-    return (psMemGetDeallocator(ptr) == (psFreeFunc)sourceFree);
-}
-
 /******************************************************************************
 pmSourceCopy(): copy the pmSource structure and contents
@@ -807,5 +802,5 @@
 // construct a realization of the source model
 bool pmSourceCacheModel (pmSource *source, psMaskType maskVal) {
-
+    PS_ASSERT_PTR_NON_NULL(source, false);
     // select appropriate model
     pmModel *model = pmSourceGetModel (NULL, source);
@@ -826,4 +821,5 @@
 // XXX this function should optionally save an existing psf image from modelFlux
 bool pmSourceCachePSF (pmSource *source, psMaskType maskVal) {
+    PS_ASSERT_PTR_NON_NULL(source, false);
 
     // select appropriate model
@@ -846,4 +842,5 @@
 {
     PS_ASSERT_PTR_NON_NULL(source, false);
+    PS_ASSERT_PTR_NON_NULL(source->peak, false);
     bool status;
 
Index: trunk/psModules/src/objects/pmSource.h
===================================================================
--- trunk/psModules/src/objects/pmSource.h	(revision 15979)
+++ trunk/psModules/src/objects/pmSource.h	(revision 15980)
@@ -3,6 +3,6 @@
  * @author EAM, IfA; GLG, MHPCC
  *
- * @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
- * @date $Date: 2007-12-13 04:05:58 $
+ * @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2008-01-02 20:39:04 $
  * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
  */
@@ -122,6 +122,4 @@
 void pmSourceFreePixels(pmSource *source);
 
-bool pmSourceTest(const psPtr ptr);
-
 /** pmSourceDefinePixels()
  *
Index: trunk/psModules/src/objects/pmSourceContour.c
===================================================================
--- trunk/psModules/src/objects/pmSourceContour.c	(revision 15979)
+++ trunk/psModules/src/objects/pmSourceContour.c	(revision 15980)
@@ -6,6 +6,6 @@
  *  @author EAM, IfA: significant modifications.
  *
- *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-11-14 22:15:42 $
+ *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2008-01-02 20:39:04 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -227,9 +227,4 @@
     int y = yc - image->row0;
 
-    // the requested point must be within the contour
-    if (image->data.F32[y][x] < threshold) {
-        return NULL;
-    }
-
     // Ensure that the starting column is allowable.
     if (x < 0) {
@@ -243,4 +238,9 @@
     }
     if (y >= image->numRows) {
+        return NULL;
+    }
+
+    // the requested point must be within the contour
+    if (image->data.F32[y][x] < threshold) {
         return NULL;
     }
Index: trunk/psModules/src/objects/pmSourceExtendedPars.h
===================================================================
--- trunk/psModules/src/objects/pmSourceExtendedPars.h	(revision 15979)
+++ trunk/psModules/src/objects/pmSourceExtendedPars.h	(revision 15980)
@@ -3,6 +3,6 @@
  * @author EAM, IfA
  *
- * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
- * @date $Date: 2007-11-10 01:09:20 $
+ * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2008-01-02 20:39:04 $
  * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
  */
@@ -56,9 +56,15 @@
 
 pmSourceExtendedPars *pmSourceExtendedParsAlloc ();
+bool psMemCheckSourceExtendedPars(psPtr ptr);
 pmSourceRadialProfile *pmSourceRadialProfileAlloc ();
+bool psMemCheckSourceRadialProfile(psPtr ptr);
 pmSourceIsophotalValues *pmSourceIsophotalValuesAlloc ();
+bool psMemCheckSourceIsophotalValues(psPtr ptr);
 pmSourcePetrosianValues *pmSourcePetrosianValuesAlloc ();
+bool psMemCheckSourcePetrosianValues(psPtr ptr);
 pmSourceKronValues *pmSourceKronValuesAlloc ();
+bool psMemCheckSourceKronValues(psPtr ptr);
 pmSourceAnnuli *pmSourceAnnuliAlloc ();
+bool psMemCheckSourceAnnuli(psPtr ptr);
 
 /// @}
Index: trunk/psModules/src/objects/pmSourceFitSet.c
===================================================================
--- trunk/psModules/src/objects/pmSourceFitSet.c	(revision 15979)
+++ trunk/psModules/src/objects/pmSourceFitSet.c	(revision 15980)
@@ -6,6 +6,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-11-15 23:18:20 $
+ *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2008-01-02 20:39:04 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -120,8 +120,23 @@
 bool pmSourceFitSetJoin (psVector *deriv, psVector *param, pmSourceFitSetData *set)
 {
-    assert (set);
-    assert (set->paramSet->n == set->derivSet->n);
-
+    PS_ASSERT_PTR_NON_NULL(set, false);
+    PS_ASSERT_PTR_NON_NULL(set->paramSet, false);
+    PS_ASSERT_PTR_NON_NULL(set->derivSet, false);
+    PS_ASSERT_VECTORS_SIZE_EQUAL(set->paramSet, set->derivSet, false);
     int n = 0;
+    int sum = 0;
+    for (int i = 0; i < set->paramSet->n; i++) {
+        sum+= set->paramSet->n;
+    }
+
+    // Must assert that the deriv and param psVectors are large enough, or else
+    // a seg fault occurs.
+    // XXX: Put the correct error call in here:
+    if (0) {
+        if (deriv->n < sum || param->n < sum) {
+            PS_ASSERT_PTR_NON_NULL(0, false);
+        }
+    }
+
     for (int i = 0; i < set->paramSet->n; i++) {
 
@@ -150,7 +165,9 @@
 bool pmSourceFitSetSplit (pmSourceFitSetData *set, const psVector *deriv, const psVector *param) 
 {
-    assert (param);
-    assert (set);
-    assert (set->paramSet->n == set->derivSet->n);
+    PS_ASSERT_VECTOR_NON_NULL(param, false);
+    PS_ASSERT_PTR_NON_NULL(set, false);
+    PS_ASSERT_PTR_NON_NULL(set->paramSet, false);
+    PS_ASSERT_PTR_NON_NULL(set->derivSet, false);
+    PS_ASSERT_VECTORS_SIZE_EQUAL(set->paramSet, set->derivSet, false);
 
     int n = 0;
@@ -175,5 +192,12 @@
                            psMinimization *myMin, int nPix, bool fitStatus)
 {
-    assert (set);
+    PS_ASSERT_PTR_NON_NULL(set, false);
+    PS_ASSERT_PTR_NON_NULL(set->paramSet, false);
+    PS_ASSERT_VECTOR_NON_NULL(dparam, false);
+    PS_ASSERT_VECTOR_NON_NULL(param, false);
+    PS_ASSERT_PTR_NON_NULL(source, false);
+    PS_ASSERT_PTR_NON_NULL(source->pixels, false);
+    PS_ASSERT_PTR_NON_NULL(myMin, false);
+
     bool onPic = true;
 
@@ -216,5 +240,5 @@
 psF32 pmSourceFitSetFunction(psVector *deriv, const psVector *param, const psVector *x)
 {
-    assert (thisSet);
+    PS_ASSERT_PTR_NON_NULL(thisSet, NAN);
     float chisqSum = 0.0;
     float chisqOne = 0.0;
Index: trunk/psModules/src/objects/pmSourceIO_PS1_DEV_0.c
===================================================================
--- trunk/psModules/src/objects/pmSourceIO_PS1_DEV_0.c	(revision 15979)
+++ trunk/psModules/src/objects/pmSourceIO_PS1_DEV_0.c	(revision 15980)
@@ -3,6 +3,6 @@
  *  @author EAM, IfA
  *
- *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-11-10 01:09:20 $
+ *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2008-01-02 20:39:04 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -69,5 +69,5 @@
 
         // no difference between PSF and non-PSF model
-        pmModel *model = pmSourceGetModel (NULL, source);
+        pmModel *model = pmSourceGetModel(NULL, source);
 
         if (model != NULL) {
@@ -81,4 +81,5 @@
             axes = pmPSF_ModelToAxes (PAR, 20.0);
         } else {
+            // XXX: This code seg faults if source->peak is NULL.
             xPos = source->peak->xf;
             yPos = source->peak->yf;
@@ -168,5 +169,6 @@
     psArray *table = psFitsReadTable (fits);
     // validate a single row of the table (must match SMP)
-
+    // XXX: The following seg-faults if table returns NULL, so I added the ASSERT
+    PS_ASSERT_PTR_NON_NULL(table, NULL);
     psArray *sources = psArrayAlloc (table->n);
 
Index: trunk/psModules/src/objects/pmSourceIO_PS1_DEV_1.c
===================================================================
--- trunk/psModules/src/objects/pmSourceIO_PS1_DEV_1.c	(revision 15979)
+++ trunk/psModules/src/objects/pmSourceIO_PS1_DEV_1.c	(revision 15980)
@@ -3,6 +3,6 @@
  *  @author EAM, IfA
  *
- *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-12-13 04:05:58 $
+ *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2008-01-02 20:39:04 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -47,6 +47,10 @@
 // XXX how do I generate the source tables which I need to send to PSPS?
 
-bool pmSourcesWrite_PS1_DEV_1 (psFits *fits, psArray *sources, psMetadata *imageHeader, psMetadata *tableHeader, char *extname, char *xsrcname)
+bool pmSourcesWrite_PS1_DEV_1 (psFits *fits, psArray *sources, psMetadata *imageHeader,
+                               psMetadata *tableHeader, char *extname, char *xsrcname)
 {
+    PS_ASSERT_PTR_NON_NULL(fits, false);
+    PS_ASSERT_PTR_NON_NULL(sources, false);
+    PS_ASSERT_PTR_NON_NULL(extname, false);
 
     psArray *table;
@@ -161,4 +165,6 @@
 psArray *pmSourcesRead_PS1_DEV_1 (psFits *fits, psMetadata *header)
 {
+    PS_ASSERT_PTR_NON_NULL(fits, false);
+    PS_ASSERT_PTR_NON_NULL(header, false);
 
     bool status;
Index: trunk/psModules/src/objects/pmSourceSky.c
===================================================================
--- trunk/psModules/src/objects/pmSourceSky.c	(revision 15979)
+++ trunk/psModules/src/objects/pmSourceSky.c	(revision 15980)
@@ -6,6 +6,6 @@
  *  @author EAM, IfA: significant modifications.
  *
- *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-09-21 00:09:05 $
+ *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2008-01-02 20:39:04 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -57,5 +57,4 @@
     PS_ASSERT_PTR_NON_NULL(source->peak, false);
     PS_ASSERT_INT_POSITIVE(Radius, false);
-    PS_ASSERT_INT_NONNEGATIVE(Radius, false);
 
     psStatsOptions statistic = psStatsSingleOption(statsOptions);
@@ -111,5 +110,4 @@
     PS_ASSERT_PTR_NON_NULL(source->peak, false);
     PS_ASSERT_INT_POSITIVE(Radius, false);
-    PS_ASSERT_INT_NONNEGATIVE(Radius, false);
 
     psStatsOptions statistic = psStatsSingleOption(statsOptions);
