blob: f33a79980f3e47719fa181c89b48d9cf2ae967d6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
From 29fced6251928e6334fa15fd28bf2c198acd4cd4 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Wed, 26 Feb 2025 16:44:48 -0800
Subject: [PATCH 1/2] Count traditional diff pattern lines correctly
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This fixes a bug I introduced on Thu Sep 5 16:37:50 2024 -0700.
Problem reported by Petr Vaněk in:
https://lists.gnu.org/archive/html/bug-patch/2025-02/msg00017.html
* src/pch.c (another_hunk): Fix method for counting number
of lines in a traditional diff hunk.
---
src/pch.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/pch.c b/src/pch.c
index 63c9a0c..d9f5c61 100644
--- a/src/pch.c
+++ b/src/pch.c
@@ -1765,9 +1765,10 @@ another_hunk (enum diff difftype, bool rev)
if (*s == ',') {
idx_t last;
s = scan_linenum (s + 1, &last);
- if (p_first >= IDX_MAX - p_ptrn_lines)
+ ptrdiff_t diff = last - p_first;
+ if (! (-1 <= diff && diff < IDX_MAX))
malformed ();
- p_ptrn_lines += 1 - p_first;
+ p_ptrn_lines = diff + 1;
}
else
p_ptrn_lines = (*s != 'a');
--
2.45.3
|