diff
--- a/libtiff/tif_ps.c
+++ b/libtiff/tif_ps.c
@@ -57,7 +57,10 @@
                                  case 1: c = *cp++; PUTHEX(c,fd);
                                  }
                                  cp += es;
-                                 if (cp > tf_buf + tf_bytesperrow) {
+                                 if (cp >= tf_buf + tf_bytesperrow) {
+                                    TIFFError(filename, "Out of bounds access in color channel processing.");
+                                    _TIFFfree((char *) tf_buf);
+                                    return;
                                     TIFFError(filename, "Color channel configuration error");
                                 }
 58                         }

