Index: /trunk/psphot/src/psphotSourceSize.c
===================================================================
--- /trunk/psphot/src/psphotSourceSize.c	(revision 19285)
+++ /trunk/psphot/src/psphotSourceSize.c	(revision 19286)
@@ -178,5 +178,5 @@
             // for each of the neighboring rows, mark the high pixels if they have a marked neighbor
             // first go up:
-            for (int iy = yo; iy >= 0; iy--) {
+            for (int iy = PS_MIN(yo, mask->numRows-2); iy >= 0; iy--) {
                 // mark the pixels in this row to the left, then the right
                 for (int ix = 0; ix < pixels->numCols; ix++) {
@@ -194,5 +194,5 @@
             }
             // next go down:
-            for (int iy = yo+1; iy < pixels->numRows; iy++) {
+            for (int iy = PS_MIN(yo+1, mask->numRows-1); iy < pixels->numRows; iy++) {
                 // mark the pixels in this row to the left, then the right
                 for (int ix = 0; ix < pixels->numCols; ix++) {
