[PATCH nft] meta: fix memory leak in tc classid parser

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Liping Zhang <liping.zhang@xxxxxxxxxxxxxx>

We forgot to free the str which was allocated by xstrdup,
so memory leak will happen.

Signed-off-by: Liping Zhang <liping.zhang@xxxxxxxxxxxxxx>
---
 src/meta.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/meta.c b/src/meta.c
index 5a6fee5..87eafee 100644
--- a/src/meta.c
+++ b/src/meta.c
@@ -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);
-- 
2.5.5


--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux