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 <renmingsh...@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
_______________________________________________ Dnsmasq-discuss mailing list Dnsmasq-discuss@lists.thekelleys.org.uk https://lists.thekelleys.org.uk/cgi-bin/mailman/listinfo/dnsmasq-discuss