From 8548796e75d05b94d29a89737db3cc1f6b4d326a Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Wed, 4 Dec 2024 21:00:12 +0300 Subject: [PATCH] Ticket #4608: mcdiff: segmentation fault on empty files merge. (get_current_hunk): immediately return if hunk list is empty. Signed-off-by: Andrew Borodin --- src/diffviewer/ydiff.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/diffviewer/ydiff.c b/src/diffviewer/ydiff.c index b543186bd..a2498275a 100644 --- a/src/diffviewer/ydiff.c +++ b/src/diffviewer/ydiff.c @@ -1926,6 +1926,10 @@ get_current_hunk (WDiff *dview, int *start_line1, int *end_line1, int *start_lin int ch; int res = 0; + /* Is file empty? */ + if (a0->len == 0) + return 0; + *start_line1 = 1; *start_line2 = 1; *end_line1 = 1;