]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
meta: fix memory leak in tc classid parser
authorLiping Zhang <liping.zhang@spreadtrum.com>
Sun, 28 Aug 2016 08:36:22 +0000 (16:36 +0800)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 30 Aug 2016 10:43:30 +0000 (12:43 +0200)
We forgot to free the str which was allocated by xstrdup,
so memory leak will happen.

Signed-off-by: Liping Zhang <liping.zhang@spreadtrum.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/meta.c

index 5a6fee5cdf793d0d3980a0469b2185ed82b3cc52..87eafeead389761290a3581b87a5451a75883604 100644 (file)
@@ -90,7 +90,7 @@ static struct error_record *tchandle_type_parse(const struct expr *sym,
                                                struct expr **res)
 {
        uint32_t handle;
-       char *str;
+       char *str = NULL;
 
        if (strcmp(sym->identifier, "root") == 0)
                handle = TC_H_ROOT;
@@ -127,6 +127,7 @@ static struct error_record *tchandle_type_parse(const struct expr *sym,
                handle = strtoull(sym->identifier, NULL, 0);
        }
 out:
+       xfree(str);
        *res = constant_expr_alloc(&sym->location, sym->dtype,
                                   BYTEORDER_HOST_ENDIAN,
                                   sizeof(handle) * BITS_PER_BYTE, &handle);