Skip to content

Commit 601ddb0

Browse files
committed
Fix yet another memory leak in conf.c
1 parent 53abaa6 commit 601ddb0

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/conf.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,8 @@ void parse_trusted_mac_list(const char *ptr) {
846846
/* check for valid format */
847847
if (!check_mac_format(possiblemac)) {
848848
debug(LOG_ERR, "[%s] not a valid MAC address to trust. See option TrustedMACList in wifidog.conf for correct this mistake.", possiblemac);
849+
free(ptrcopy);
850+
free(mac);
849851
return;
850852
} else {
851853
if (sscanf(possiblemac, " %17[A-Fa-f0-9:]", mac) == 1) {
@@ -860,10 +862,10 @@ void parse_trusted_mac_list(const char *ptr) {
860862
} else {
861863
/* Advance to the last entry */
862864
for (p = config.trustedmaclist; p->next != NULL; p = p->next);
863-
p->next = safe_malloc(sizeof(t_trusted_mac));
864-
p = p->next;
865-
p->mac = safe_strdup(mac);
866-
p->next = NULL;
865+
p->next = safe_malloc(sizeof(t_trusted_mac));
866+
p = p->next;
867+
p->mac = safe_strdup(mac);
868+
p->next = NULL;
867869
}
868870
}
869871
}

0 commit comments

Comments
 (0)