diff mbox

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

Message ID 1472373382-20104-1-git-send-email-zlpnobody@163.com
State Accepted
Delegated to: Pablo Neira
Headers show

Commit Message

Liping Zhang Aug. 28, 2016, 8:36 a.m. UTC
From: Liping Zhang <liping.zhang@spreadtrum.com>

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>
---
 src/meta.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Pablo Neira Ayuso Aug. 30, 2016, 10:43 a.m. UTC | #1
On Sun, Aug 28, 2016 at 04:36:22PM +0800, Liping Zhang wrote:
> From: Liping Zhang <liping.zhang@spreadtrum.com>
> 
> We forgot to free the str which was allocated by xstrdup,
> so memory leak will happen.

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

Patch

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);