]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
ifstat: Fix memleak in error case
authorPhil Sutter <phil@nwl.cc>
Thu, 17 Aug 2017 17:09:28 +0000 (19:09 +0200)
committerStephen Hemminger <stephen@networkplumber.org>
Fri, 18 Aug 2017 16:39:52 +0000 (09:39 -0700)
Signed-off-by: Phil Sutter <phil@nwl.cc>
misc/ifstat.c

index a853ee6d7e3b3fbdd0246d420e18ab35fcd7368a..8fa354265a9a1a1fb55710b47ad0117950507e16 100644 (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));