(wrong string) ée

From: <git_AT_suckless.org>
Date: Fri, 20 Jan 2017 11:45:19 +0100 (CET)

commit 6990c64cf757d230800bacb489eb1db3fc790e3a
Author: Mattias Andrée <maandree_AT_kth.se>
AuthorDate: Fri Jan 20 11:16:36 2017 +0100
Commit: Mattias Andrée <maandree_AT_kth.se>
CommitDate: Fri Jan 20 11:17:02 2017 +0100

    Fix blind-crop
    
    Signed-off-by: Mattias Andrée <maandree_AT_kth.se>

diff --git a/TODO b/TODO
index 4cf63b2..f689e7b 100644
--- a/TODO
+++ b/TODO
_AT_@ -13,7 +13,6 @@ blind-find-frame a graphical tool for locating frames, should highlight key fram
 Add [-j jobs] to blind-from-video and blind-to-video.
 
 UNTESTED:
- blind-crop
         blind-cut
         blind-extend
         blind-rewrite-head
diff --git a/src/blind-crop.c b/src/blind-crop.c
index bf5a930..f45875e 100644
--- a/src/blind-crop.c
+++ b/src/blind-crop.c
_AT_@ -37,7 +37,8 @@ main(int argc, char *argv[])
         stream.file = "<stdin>";
         stream.fd = STDIN_FILENO;
         einit_stream(&stream);
- if (left + width > stream.width || top + height > stream.height)
+ if (left > SIZE_MAX - width || left + width > stream.width ||
+ top > SIZE_MAX - height || top + height > stream.height)
                 eprintf("crop area extends beyond original image\n");
         if (tile) {
                 fprint_stream_head(stdout, &stream);
_AT_@ -59,10 +60,10 @@ main(int argc, char *argv[])
 
         left *= stream.pixel_size;
         if (!tile) {
- off = top * irown;
+ off = top * irown + left;
         } else {
- off = (orown - (left % orown)) % orown;
- yoff = (height - (top % height)) % height;
+ off = (orown - left % orown) % orown;
+ yoff = (height - top % height) % height;
         }
 
         memcpy(buf, stream.buf, ptr = stream.ptr);
_AT_@ -72,9 +73,9 @@ main(int argc, char *argv[])
                                 memcpy(image + y * orown, buf + y * irown + off, orown);
                 } else {
                         for (ptr = y = 0; y < stream.height; y++) {
- p = buf + ((y + yoff) % height) * irown + left;
+ p = buf + ((y + yoff) % height + top) * irown;
                                 for (x = 0; x < irown; x++, ptr++)
- image[ptr++] = p[(x + off) % orown];
+ image[ptr] = p[(x + off) % orown + left];
                         }
                 }
                 ewriteall(STDOUT_FILENO, image, m, "<stdout>");
Received on Fri Jan 20 2017 - 11:45:19 CET

This archive was generated by hypermail 2.3.0 : Fri Jan 20 2017 - 11:48:17 CET