tc: pedit: fix memory leak in print_pedit

keys_ex is dinamically allocated with calloc on line 770, but
is not freed in case of error at line 823.

Fixes: 081d6c310d ("tc: pedit: Support JSON dumping")
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
This commit is contained in:
Andrea Claudi 2020-12-11 19:53:03 +01:00 committed by Stephen Hemminger
parent ec1346acbe
commit 0d78e8eabf
1 changed files with 3 additions and 1 deletions

View File

@ -819,8 +819,10 @@ static int print_pedit(struct action_util *au, FILE *f, struct rtattr *arg)
print_uint(PRINT_FP, NULL, "\n\t key #%d at ", i);
err = print_pedit_location(f, htype, key->off);
if (err)
if (err) {
free(keys_ex);
return err;
}
/* In FP, report the "set" command as "val" to keep
* backward compatibility. Report the true name in JSON.