diff --git a/src/config/dnsmasq_config.c b/src/config/dnsmasq_config.c index afef19ab9..a6dad4b8e 100644 --- a/src/config/dnsmasq_config.c +++ b/src/config/dnsmasq_config.c @@ -841,6 +841,12 @@ bool read_legacy_dhcp_static_config(void) return false; } + // Clear out config.dhcp.hosts array if it exists + if(config.dhcp.hosts.v.json != NULL) + cJSON_Delete(config.dhcp.hosts.v.json); + config.dhcp.hosts.v.json = cJSON_CreateArray(); + + // Read file line by line char *linebuffer = NULL; size_t size = 0u; errno = 0; @@ -898,6 +904,12 @@ bool read_legacy_cnames_config(void) return false; } + // Clear out config.dns.cnameRecords array if it exists + if(config.dns.cnameRecords.v.json != NULL) + cJSON_Delete(config.dns.cnameRecords.v.json); + config.dns.cnameRecords.v.json = cJSON_CreateArray(); + + // Read file line by line char *linebuffer = NULL; size_t size = 0u; errno = 0; @@ -955,6 +967,12 @@ bool read_legacy_custom_hosts_config(void) return false; } + // Clear out config.dns.hosts array if it exists + if(config.dns.hosts.v.json != NULL) + cJSON_Delete(config.dns.hosts.v.json); + config.dns.hosts.v.json = cJSON_CreateArray(); + + // Read file line by line char *linebuffer = NULL; size_t size = 0u; errno = 0;