7
0
forked from pool/diffutils
Files
diffutils/diff-fix-allocation-typo-leading-to-crashes.patch

28 lines
956 B
Diff
Raw Normal View History

From: Paul Eggert <eggert@cs.ucla.edu>
Subject: diff: fix allocation typo leading to crashes
Date: Fri Feb 28 22:53:28 2025 -0800
Git-repo: https://git.savannah.gnu.org/git/diffutils.git
Git-commit: e9f8e6a439fd607adbdd846ab93267dc367b5c79
References: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=77265
Signed-off-by: Tony Jones <tonyj@suse.de>
diff: fix allocation typo leading to crashes
But reported by Nick Smallbone, with one-line fix by
Collin Funk <https://bugs.gnu.org/76613>.
* src/io.c (find_and_hash_each_line): Fix size computation.
diff --git a/src/io.c b/src/io.c
index a62c529..eba4aba 100644
--- a/src/io.c
+++ b/src/io.c
@@ -1012,7 +1012,7 @@ find_and_hash_each_line (struct file_data *current)
linbuf += linbuf_base;
linbuf = xpalloc (linbuf, &n, 1, -1, sizeof *linbuf);
linbuf -= linbuf_base;
- alloc_lines = n - linbuf_base;
+ alloc_lines = linbuf_base + n;
}
linbuf[line] = p;