From 93adb4ad8dfd444c616d0aa910a6b2fef2cd24dd Mon Sep 17 00:00:00 2001 From: JinWang An Date: Mon, 22 Feb 2021 15:17:10 +0900 Subject: [PATCH] [CVE-2014-9637] Fail when out of memory in set_hunkmax() src/pch.c (another_hunk): Call set_hunkmax() from here to make sure it is called even when falling back from plan A to plan B. (open_patch_file): No need to call set_hunkmax() anymore. src/pch.c (set_hunkmax): Fail when out of memory. Make static. src/pch.h: Remove set_hunkmax() prototype. Change-Id: Ibbab473998ef297844787b033cca52f8a7b4e86d Signed-off-by: JinWang An --- src/pch.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pch.c b/src/pch.c index 9661be2..f958b19 100644 --- a/src/pch.c +++ b/src/pch.c @@ -166,11 +166,11 @@ void set_hunkmax (void) { if (!p_line) - p_line = (char **) malloc (hunkmax * sizeof *p_line); + p_line = (char **) xmalloc (hunkmax * sizeof *p_line); if (!p_len) - p_len = (size_t *) malloc (hunkmax * sizeof *p_len); + p_len = (size_t *) xmalloc (hunkmax * sizeof *p_len); if (!p_Char) - p_Char = malloc (hunkmax * sizeof *p_Char); + p_Char = xmalloc (hunkmax * sizeof *p_Char); } /* Enlarge the arrays containing the current hunk of patch. */ -- 2.34.1