Index: trunk/psLib/src/imageops/psImageConvolve.c
===================================================================
--- trunk/psLib/src/imageops/psImageConvolve.c	(revision 32728)
+++ trunk/psLib/src/imageops/psImageConvolve.c	(revision 32729)
@@ -834,4 +834,5 @@
 		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;
@@ -841,5 +842,5 @@
 	    /* If that's all the pixels we have, then we're done already */
 	    if (Nx > Nrange) {
-		/* Smooth middle pixels */
+		/* Smooth middle pixels; if Nx < 2*Nrange, this pass is skipped */
 		for (int i = Nrange; i < Nx - Nrange; i++, vi++) {
 		    psF32 *vr = vi - Nrange;
@@ -847,4 +848,5 @@
 		    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;
 		    }
@@ -852,5 +854,7 @@
 		}
 		/* Smooth last Nrange pixels, with renorm */
-		for (int i = Nx - Nrange; i < Nx; i++, vi++) {
+		// 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++) {
 		    psF32 *vr = vi - Nrange;
 		    psF32 *vg = gauss - Nrange;
@@ -858,4 +862,5 @@
 		    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;
