[CVE-2014-9637] Fail when out of memory in set_hunkmax()
authorJinWang An <jinwang.an@samsung.com>
Mon, 22 Feb 2021 06:17:10 +0000 (15:17 +0900)
committerJinWang An <jinwang.an@samsung.com>
Wed, 17 Mar 2021 04:05:45 +0000 (13:05 +0900)
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 <jinwang.an@samsung.com>
src/pch.c

index 9661be254c19eaffbffc874ffc6b2ee62724d951..f958b1924b46f56c109e535f07973463ebaa275d 100644 (file)
--- 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. */