From f11ca2400c926e874caa5e1e1baa140f5d49aed5 Mon Sep 17 00:00:00 2001 From: ValdikSS Date: Sat, 16 Dec 2017 17:53:06 +0300 Subject: [PATCH] Fix memory leak in dnsredir --- dnsredir.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dnsredir.c b/dnsredir.c index 7597894..1cece8b 100644 --- a/dnsredir.c +++ b/dnsredir.c @@ -106,10 +106,10 @@ static int check_get_udp_conntrack_key(const char *key, udp_connrecord_t **connr static int add_udp_conntrack(const uint32_t srcip, const uint16_t srcport, const uint32_t dstip, const uint16_t dstport) { - udp_connrecord_t *tmp_connrecord = malloc(sizeof(udp_connrecord_t)); if (!(srcip && srcport && dstip && dstport)) return FALSE; + udp_connrecord_t *tmp_connrecord = malloc(sizeof(udp_connrecord_t)); construct_key(srcip, srcport, tmp_connrecord->key); if (!check_get_udp_conntrack_key(tmp_connrecord->key, NULL)) { @@ -121,6 +121,7 @@ static int add_udp_conntrack(const uint32_t srcip, const uint16_t srcport, return TRUE; } debug("Not added UDP conntrack\n"); + free(tmp_connrecord); return FALSE; }