patch/backport-Avoid-invalid-memory-access-in-context-format-diffs.patch

29 lines
783 B
Diff
Raw Normal View History

From 46136e6440f78b4a21eaeaeabef2b4fcb482c158 Mon Sep 17 00:00:00 2001
From: Andreas Gruenbacher <agruen@gnu.org>
Date: Mon, 15 Jul 2019 19:10:02 +0200
Subject: [PATCH 4/8] Avoid invalid memory access in context format diffs
* src/pch.c (another_hunk): Avoid invalid memory access in context format
diffs.
Signed-off-by: Xibo.Wang <wangxb12@chinatelecom.cn>
---
src/pch.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/pch.c b/src/pch.c
index aa0caf4..87e6f93 100644
--- a/src/pch.c
+++ b/src/pch.c
@@ -1335,6 +1335,7 @@ another_hunk (enum diff difftype, bool rev)
ptrn_prefix_context = context;
ptrn_suffix_context = context;
if (repl_beginning
+ || p_end <= 0
|| (p_end
!= p_ptrn_lines + 1 + (p_Char[p_end - 1] == '\n')))
{
--
1.8.3.1