tools, bpftool: Fix memory leak in codegen error cases
Free the memory allocated for the template on error paths in function codegen. Signed-off-by: Tobias Klauser <tklauser@distanz.ch> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Andrii Nakryiko <andriin@fb.com> Link: https://lore.kernel.org/bpf/20200610130804.21423-1-tklauser@distanz.ch
This commit is contained in:
parent
bd6fecb9a9
commit
d4060ac969
@ -224,6 +224,7 @@ static int codegen(const char *template, ...)
|
||||
} else {
|
||||
p_err("unrecognized character at pos %td in template '%s'",
|
||||
src - template - 1, template);
|
||||
free(s);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
@ -234,6 +235,7 @@ static int codegen(const char *template, ...)
|
||||
if (*src != '\t') {
|
||||
p_err("not enough tabs at pos %td in template '%s'",
|
||||
src - template - 1, template);
|
||||
free(s);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user