naccyde / rpms / iproute

Forked from rpms/iproute 9 months ago
Clone
36cfb7
From 78ff1fa1a2ff22e6fb7dc0a689e5a4861826431e Mon Sep 17 00:00:00 2001
36cfb7
From: Andrea Claudi <aclaudi@redhat.com>
36cfb7
Date: Mon, 29 Apr 2019 20:07:22 +0200
36cfb7
Subject: [PATCH] ifstat: Fix memleak in error case
36cfb7
36cfb7
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1465646
36cfb7
Upstream Status: iproute2.git commit 35f6adefb8f9d
36cfb7
36cfb7
commit 35f6adefb8f9d56437f5455ac8c0c3cc329e3317
36cfb7
Author: Phil Sutter <phil@nwl.cc>
36cfb7
Date:   Thu Aug 17 19:09:28 2017 +0200
36cfb7
36cfb7
    ifstat: Fix memleak in error case
36cfb7
36cfb7
    Signed-off-by: Phil Sutter <phil@nwl.cc>
36cfb7
---
36cfb7
 misc/ifstat.c | 4 +++-
36cfb7
 1 file changed, 3 insertions(+), 1 deletion(-)
36cfb7
36cfb7
diff --git a/misc/ifstat.c b/misc/ifstat.c
36cfb7
index a853ee6d7e3b3..8fa354265a9a1 100644
36cfb7
--- a/misc/ifstat.c
36cfb7
+++ b/misc/ifstat.c
36cfb7
@@ -143,8 +143,10 @@ static int get_nlmsg_extended(const struct sockaddr_nl *who,
36cfb7
 		struct rtattr *attr;
36cfb7
 
36cfb7
 		attr = parse_rtattr_one_nested(sub_type, tb[filter_type]);
36cfb7
-		if (attr == NULL)
36cfb7
+		if (attr == NULL) {
36cfb7
+			free(n);
36cfb7
 			return 0;
36cfb7
+		}
36cfb7
 		memcpy(&n->val, RTA_DATA(attr), sizeof(n->val));
36cfb7
 	}
36cfb7
 	memset(&n->rate, 0, sizeof(n->rate));
36cfb7
-- 
e138d9
2.21.0
36cfb7