blob: 0590f47d9a37ca40c14397ae2e6dd789ab90f694 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
From ea6cc338042094f8023d224e53c244da158e6499 Mon Sep 17 00:00:00 2001
From: Simon Kelley <simon@thekelleys.org.uk>
Date: Tue, 18 Sep 2018 23:21:17 +0100
Subject: [PATCH] Handle memory allocation failure in make_non_terminals()
Thanks to Kristian Evensen for spotting the problem.
Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
---
src/cache.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
--- a/src/cache.c
+++ b/src/cache.c
@@ -1360,7 +1360,7 @@ void cache_add_dhcp_entry(char *host_nam
static void make_non_terminals(struct crec *source)
{
char *name = cache_get_name(source);
- struct crec* crecp, *tmp, **up;
+ struct crec *crecp, *tmp, **up;
int type = F_HOSTS | F_CONFIG;
#ifdef HAVE_DHCP
if (source->flags & F_DHCP)
@@ -1434,12 +1434,15 @@ static void make_non_terminals(struct cr
#endif
crecp = whine_malloc(sizeof(struct crec));
- *crecp = *source;
- crecp->flags &= ~(F_IPV4 | F_IPV6 | F_CNAME | F_DNSKEY | F_DS | F_REVERSE);
- crecp->flags |= F_NAMEP;
- crecp->name.namep = name;
-
- cache_hash(crecp);
+ if (crecp)
+ {
+ *crecp = *source;
+ crecp->flags &= ~(F_IPV4 | F_IPV6 | F_CNAME | F_DNSKEY | F_DS | F_REVERSE);
+ crecp->flags |= F_NAMEP;
+ crecp->name.namep = name;
+
+ cache_hash(crecp);
+ }
}
}
|