From 97d65859bc29ee334012e9c73022d8a8e55ed586 Mon Sep 17 00:00:00 2001
From: Su Laus <sulau@freenet.de>
Date: Sat, 21 Jan 2023 15:58:10 +0000
Subject: [PATCH] tiffcrop: Correct simple copy paste error. Fix #488.

Reference:https://gitlab.com/libtiff/libtiff/-/commit/d1b6b9c1b3cae2d9e37754506c1ad8f4f7b646b5
Conflict:NA
---
 tools/tiffcrop.c     |  2 +-
 1 files changed, 1 insertions(+), 1 deletion(-)
 create mode 100644 tools/tiffcrop.c.rej

diff --git a/tools/tiffcrop.c b/tools/tiffcrop.c
index 2c251aa..d3f7881 100644
--- a/tools/tiffcrop.c
+++ b/tools/tiffcrop.c
@@ -7584,11 +7584,11 @@ processCropSelections(struct image_data *image, struct crop_mask *crop,
       crop_buff = seg_buffs[i].buffer; 
       if (!crop_buff)
         crop_buff = (unsigned char *)limitMalloc(cropsize + NUM_BUFF_OVERSIZE_BYTES);
       else
         {
-        prev_cropsize = seg_buffs[0].size;
+        prev_cropsize = seg_buffs[i].size;
         if (prev_cropsize < cropsize)
           {
           next_buff = _TIFFrealloc(crop_buff, cropsize + NUM_BUFF_OVERSIZE_BYTES);
           if (! next_buff)
             {
-- 
2.33.0
