I noticed this issue while looking at allocation of hash structures for:
https://bugs.gnu.org/48189

Addressed with the attached.

cheers,
Pádraig
>From f1d2e8e2893961812483dcbd4ada0a68defa6653 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <[email protected]>
Date: Mon, 3 May 2021 18:53:35 +0100
Subject: [PATCH] copy: exit immediately upon failure to allocate hash memory

* src/copy.c (dest_info_init, src_info_init): Terminate immediately
upon memory exhaustion.
---
 src/copy.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/copy.c b/src/copy.c
index 3e1abee28..af16bab69 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -1953,6 +1953,8 @@ dest_info_init (struct cp_options *x)
                        triple_hash,
                        triple_compare,
                        triple_free);
+  if (! x->dest_info)
+    xalloc_die();
 }
 
 /* Initialize the hash table implementing a set of F_triple entries
@@ -1975,6 +1977,8 @@ src_info_init (struct cp_options *x)
                        triple_hash_no_name,
                        triple_compare,
                        triple_free);
+  if (! x->src_info)
+    xalloc_die();
 }
 
 /* When effecting a move (e.g., for mv(1)), and given the name DST_NAME
-- 
2.26.2

Reply via email to