
<                         for (; cc < tf_bytesperrow; cc += samplesperpixel) {
---
>                         unsigned char *end = tf_buf + tf_bytesperrow;
>                         for (; cp < end; cp += samplesperpixel) {
>                             cc = cp - tf_buf;
