Index: trunk/psLib/src/imageops/psImageConvolve.c
===================================================================
--- trunk/psLib/src/imageops/psImageConvolve.c	(revision 32729)
+++ trunk/psLib/src/imageops/psImageConvolve.c	(revision 32745)
@@ -626,5 +626,5 @@
                 /* Smooth first Nrange pixels, with renorm */ \
                 for (int i = 0; i < xMax; i++, vi++, vo++) { \
-		    int convRange = PS_MIN(Nrange + 1, Nx - xMax + 1);  \
+		    int convRange = PS_MIN(Nrange + 1, Nx - i);  \
                     ps##TYPE *vr = vi - i; \
                     ps##TYPE *vg = gauss - i; \
@@ -650,6 +650,7 @@
                     } \
                     /* Smooth last Nrange pixels, with renorm */ \
-                    /* XXX does this miss the last column? */ \
-                    for (int i = Nx - Nrange; i < Nx; i++, vi++, vo++) { \
+		    /* if Nx < 2*Nrange, this pass starts at i == Nrange */ \
+		    int xMin = PS_MAX(Nx - Nrange, Nrange); \
+                    for (int i = xMin; i < Nx; i++, vi++, vo++) { \
                         ps##TYPE *vr = vi - Nrange; \
                         ps##TYPE *vg = gauss - Nrange; \
@@ -717,6 +718,8 @@
                 calculation = save; \
             } \
-            /* Smooth last Nrange pixels, with renorm */ \
-            for (int j = Ny - Nrange; j < Ny; j++) { \
+            /* Smooth last Nrange pixels, with renorm */		\
+	    /* if Ny < 2*Nrange, this pass starts at j == Nrange */ \
+	    int yMin = PS_MAX(Ny - Nrange, Nrange); \
+            for (int j = yMin; j < Ny; j++) { \
                 /* save the Nrange-offset output row, then zero */ \
                 memset(calculation->data.TYPE, 0, Nx*sizeof(ps##TYPE)); \
@@ -834,5 +837,4 @@
 		double s = 0.0;
 		for (int n = -i; n < convRange; n++, vr++, vg++) {
-		    psAssert (vr - image->data.F32[j] < image->numCols, "counting error");
 		    s += *vg * *vr;
 		    g += *vg;
@@ -848,5 +850,4 @@
 		    double s = 0;
 		    for (int n = -Nrange; n < Nrange + 1; n++, vr++, vg++) {
-			psAssert (vr - image->data.F32[j] < image->numCols, "counting error");
 			s += *vg * *vr;
 		    }
@@ -862,5 +863,4 @@
 		    double s = 0.0;
 		    for (int n = -Nrange; n < Nx - i; n++, vr++, vg++) {
-			psAssert (vr - image->data.F32[j] < image->numCols, "counting error");
 			s += *vg * *vr;
 			g += *vg;
@@ -904,5 +904,7 @@
 		}
 		/* Smooth last Nrange pixels, with renorm */
-		for (int j = Ny - Nrange; j < Ny; j++) {
+		// if Ny < 2*Nrange, this pass starts at j == Nrange
+		int yMin = PS_MAX(Ny - Nrange, Nrange);
+		for (int j = yMin; j < Ny; j++) {
 		    psF32 *vg = gauss - Nrange;
 		    double g = 0.0;
