mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 18:28:25 +00:00
Handle memory allocation failure in make_non_terminals()
Thanks to Kristian Evensen for spotting the problem.
This commit is contained in:
15
src/cache.c
15
src/cache.c
@@ -1360,7 +1360,7 @@ void cache_add_dhcp_entry(char *host_name, int prot,
|
|||||||
static void make_non_terminals(struct crec *source)
|
static void make_non_terminals(struct crec *source)
|
||||||
{
|
{
|
||||||
char *name = cache_get_name(source);
|
char *name = cache_get_name(source);
|
||||||
struct crec* crecp, *tmp, **up;
|
struct crec *crecp, *tmp, **up;
|
||||||
int type = F_HOSTS | F_CONFIG;
|
int type = F_HOSTS | F_CONFIG;
|
||||||
#ifdef HAVE_DHCP
|
#ifdef HAVE_DHCP
|
||||||
if (source->flags & F_DHCP)
|
if (source->flags & F_DHCP)
|
||||||
@@ -1434,12 +1434,15 @@ static void make_non_terminals(struct crec *source)
|
|||||||
#endif
|
#endif
|
||||||
crecp = whine_malloc(sizeof(struct crec));
|
crecp = whine_malloc(sizeof(struct crec));
|
||||||
|
|
||||||
*crecp = *source;
|
if (crecp)
|
||||||
crecp->flags &= ~(F_IPV4 | F_IPV6 | F_CNAME | F_DNSKEY | F_DS | F_REVERSE);
|
{
|
||||||
crecp->flags |= F_NAMEP;
|
*crecp = *source;
|
||||||
crecp->name.namep = name;
|
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);
|
cache_hash(crecp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user