patch 9.1.1926: xdiff: Coverity warning with MAX_CNT/UINT_MAX usage

Commit: 
https://github.com/vim/vim/commit/cf7c0038a4c999409264559c085a7c8d293cdf8a
Author: Yee Cheng Chin <[email protected]>
Date:   Sun Nov 23 19:24:10 2025 +0000

    patch 9.1.1926: xdiff: Coverity warning with MAX_CNT/UINT_MAX usage
    
    Problem:  xdiff: Coverity warning with MAX_CNT/UINT_MAX usage
              (after v9.1.1921)
    Solution: Replace XDL_MIN macro to a manual check.
              (Yee Cheng Chin)
    
    In the recent xdiff upstream sync (#18765), MAX_CNT in xhistogram was
    switched back to using UINT_MAX to match upstream. This exposed an issue
    in xdiff that using using min() to compare against the max integer will
    not work as the number will just overflow. Switch the check to be done
    in a saturating add that respects integer overflow.
    
    related: #18765
    closes: #18792
    
    Signed-off-by: Yee Cheng Chin <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/src/version.c b/src/version.c
index a02a9e2d8..b34018b85 100644
--- a/src/version.c
+++ b/src/version.c
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1926,
 /**/
     1925,
 /**/
diff --git a/src/xdiff/xhistogram.c b/src/xdiff/xhistogram.c
index 6dc450b1f..50f208c9f 100644
--- a/src/xdiff/xhistogram.c
+++ b/src/xdiff/xhistogram.c
@@ -122,7 +122,7 @@ static int scanA(struct histindex *index, int line1, int 
count1)
                                NEXT_PTR(index, ptr) = rec->ptr;
                                rec->ptr = ptr;
                                /* cap rec->cnt at MAX_CNT */
-                               rec->cnt = XDL_MIN(MAX_CNT, rec->cnt + 1);
+                               rec->cnt = (rec->cnt < MAX_CNT) ? rec->cnt + 1 
: rec->cnt;
                                LINE_MAP(index, ptr) = rec;
                                goto continue_scan;
                        }

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1vNFme-000Ejc-2A%40256bit.org.

Raspunde prin e-mail lui