statzone

DNS zone file analyzer targeted at TLD zones
Log | Files | Refs | README | LICENSE

commit daa537011774cb4c67fc04798a1450d7552205fd
parent f5a121e835be7e47fa590475796b0aabe7766180
Author: Frederic Cambus <fred@statdns.com>
Date:   Fri,  2 Aug 2019 10:58:41 +0200

Plug memory leak, always free previousDomain before calling strdup(3).

Diffstat:
Msrc/statzone.c | 5++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/statzone.c b/src/statzone.c @@ -44,7 +44,7 @@ int8_t getoptFlag; char *intputFile; char *domain; -char *previousDomain = ""; +char *previousDomain; char *rdata; struct my_struct { @@ -119,6 +119,8 @@ main(int argc, char *argv[]) { return EXIT_FAILURE; } + previousDomain = strdup(""); + while (fgets(lineBuffer, LINE_LENGTH_MAX, zoneFile)) { if (*lineBuffer == ';') /* Comments */ continue; @@ -181,6 +183,7 @@ main(int argc, char *argv[]) { if (strlen(previousDomain) != strlen(domain) || strncmp(domain, previousDomain, strlen(domain))) { results.domains++; + free(previousDomain); previousDomain = strdup(domain); if (!strncmp(domain, "xn--", 4)) results.idn++;