[Dnsmasq-discuss] [PATCH] Set pointers to NULL after memory is freed
renmingshuai
renmingshuai at huawei.com
Sun Oct 8 08:44:54 UTC 2023
Set pointers to NULL after memory is freed to reduce dangling pointers, although they are later set to new values.
>From 5567d99099191f0cdb2922555e6ade2634f94f30 Mon Sep 17 00:00:00 2001
From: renmingshuai <renmingshuai at huawei.com>
Date: Sun, 8 Oct 2023 16:06:46 +0800
Subject: [PATCH] Set pointers to NULL after memory is freed
---
src/option.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/option.c b/src/option.c
index 286f06b..23601e1 100644
--- a/src/option.c
+++ b/src/option.c
@@ -5732,6 +5732,7 @@ static void clear_dynamic_conf(void)
else
up = &configs->next;
}
+ daemon->dhcp_conf = NULL;
}
static void clear_dhcp_opt(struct dhcp_opt **dhcp_opts)
@@ -5755,8 +5756,10 @@ static void clear_dhcp_opt(struct dhcp_opt **dhcp_opts)
static void clear_dynamic_opt(void)
{
clear_dhcp_opt(&daemon->dhcp_opts);
+ daemon->dhcp_opts = NULL;
#ifdef HAVE_DHCP6
clear_dhcp_opt(&daemon->dhcp_opts6);
+ daemon->dhcp_opts6 = NULL;
#endif
}
--
2.33.0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20231008/0e25e94e/attachment-0001.htm>
More information about the Dnsmasq-discuss
mailing list