]> git.proxmox.com Git - mirror_iproute2.git/blobdiff - tc/tc_util.c
tc: fix memory leak in error path
[mirror_iproute2.git] / tc / tc_util.c
index ab717890bb2a44b4c53a756bd8350b4ed4428a22..1377b536e72fa463c58bb0dcb05a9d69c9f23d7a 100644 (file)
@@ -195,7 +195,7 @@ static int parse_percent_rate(char *rate, const char *str, const char *dev)
        long dev_mbit;
        int ret;
        double perc, rate_mbit;
-       char *str_perc;
+       char *str_perc = NULL;
 
        if (!dev[0]) {
                fprintf(stderr, "No device specified; specify device to rate limit by percentage\n");
@@ -230,6 +230,7 @@ static int parse_percent_rate(char *rate, const char *str, const char *dev)
        return 0;
 
 malf:
+       free(str_perc);
        fprintf(stderr, "Specified rate value could not be read or is malformed\n");
        return -1;
 }