ifstat: Fix memleak in error case

Signed-off-by: Phil Sutter <phil@nwl.cc>
This commit is contained in:
Phil Sutter 2017-08-17 19:09:28 +02:00 committed by Stephen Hemminger
parent 6ac5943bdd
commit 35f6adefb8
1 changed files with 3 additions and 1 deletions

View File

@ -143,8 +143,10 @@ static int get_nlmsg_extended(const struct sockaddr_nl *who,
struct rtattr *attr;
attr = parse_rtattr_one_nested(sub_type, tb[filter_type]);
if (attr == NULL)
if (attr == NULL) {
free(n);
return 0;
}
memcpy(&n->val, RTA_DATA(attr), sizeof(n->val));
}
memset(&n->rate, 0, sizeof(n->rate));