Skip to content

Commit

Permalink
examples/qos_sched: fix memory leak in args parsing
Browse files Browse the repository at this point in the history
[ upstream commit db8aee153e43375538667c6f861e981a47574476 ]

Should free the memory which allocated by strdup().

Fixes: 035b6a4 ("examples/qos_sched: fix out-of-bounds option parsing")

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
  • Loading branch information
fengchengwen authored and bluca committed Mar 7, 2024
1 parent 25bcc3c commit 7d35dff
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion examples/qos_sched/args.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,10 @@ app_parse_opt_vals(const char *conf_str, char separator, uint32_t n_vals, uint32

n_tokens = rte_strsplit(string, strnlen(string, 32), tokens, n_vals, separator);

if (n_tokens > MAX_OPT_VALUES)
if (n_tokens > MAX_OPT_VALUES) {
free(string);
return -1;
}

for (i = 0; i < n_tokens; i++)
opt_vals[i] = (uint32_t)atol(tokens[i]);
Expand Down

0 comments on commit 7d35dff

Please sign in to comment.