From 5701b36e3d099cbae446b869ff58b69a7fd74390 Mon Sep 17 00:00:00 2001 From: Takashi Sawanaka Date: Sat, 7 Oct 2023 18:44:16 +0900 Subject: [PATCH] Fix a crash problem when the Diff algorithm is set to something other than default and one file does not have an EOL of the last line and the other file has an EOL of the last line. --- Src/xdiff_gnudiff_compat.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Src/xdiff_gnudiff_compat.cpp b/Src/xdiff_gnudiff_compat.cpp index d1f59690634..f05674986e2 100644 --- a/Src/xdiff_gnudiff_compat.cpp +++ b/Src/xdiff_gnudiff_compat.cpp @@ -182,9 +182,13 @@ struct change * diff_2_files_xdiff (struct file_data filevec[], int* bin_status, { script = diff_2_buffers_xdiff( filevec[0].prefix_end, - filevec[0].suffix_begin - filevec[0].prefix_end, + filevec[0].suffix_begin - filevec[0].prefix_end - + ((filevec[0].suffix_begin == filevec[0].buffer + filevec[0].buffered_chars) + ? filevec[0].missing_newline : 0), filevec[1].prefix_end, - filevec[1].suffix_begin - filevec[1].prefix_end, + filevec[1].suffix_begin - filevec[1].prefix_end - + ((filevec[1].suffix_begin == filevec[1].buffer + filevec[1].buffered_chars) + ? filevec[1].missing_newline : 0), xdl_flags); if (bMoved_blocks_flag) moved_block_analysis(&script, filevec);