aboutsummaryrefslogblamecommitdiffstats
path: root/main/less/0001-Shouldn-t-use-memcpy-to-copy-to-overlapping-range.patch
blob: b6381d1320a98c02a2611a9225b36c2ecfa2ff17 (plain) (tree)



























                                                                                         
From df845a5315e1e12df352beca4bd722206d5e081e Mon Sep 17 00:00:00 2001
From: Mark Nudelman <markn@greenwoodsoftware.com>
Date: Sun, 16 May 2021 11:10:38 -0700
Subject: [PATCH] Shouldn't use memcpy to copy to overlapping range.

---
 line.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/line.c b/line.c
index 5d4596d..5414af8 100644
--- a/line.c
+++ b/line.c
@@ -740,8 +740,12 @@ store_char(ch, a, rep, pos)
 		if (linebuf.end > linebuf.print)
 		{
 			/* Shift left enough to put last byte of this char at print-1. */
-			memcpy(&linebuf.buf[0], &linebuf.buf[replen], linebuf.print);
-			memcpy(&linebuf.attr[0], &linebuf.attr[replen], linebuf.print);
+			int i;
+			for (i = 0; i < linebuf.print; i++)
+			{
+				linebuf.buf[i] = linebuf.buf[i+replen];
+				linebuf.attr[i] = linebuf.attr[i+replen];
+			}
 			linebuf.end -= replen;
 			cshift += w;
 			/*