[PATCH 30/38] trace-cmd listen: prevent memory leak in communicate_with_client()
"Jerome Marchand" <[email protected]>
| Newsgroups | org.kernel.vger.linux-trace-devel |
|---|---|
| Message-ID | <[email protected]> |
Free option in the error path. Fixes a RESOURCE_LEAK error (CWE-772) Signed-off-by: Jerome Marchand <[email protected]> --- tracecmd/trace-listen.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tracecmd/trace-listen.c b/tracecmd/trace-listen.c index 09f442c7..da46d09e 100644 --- a/tracecmd/trace-listen.c +++ b/tracecmd/trace-listen.c @@ -456,8 +456,10 @@ static int communicate_with_client(struct tracecmd_msg_handle *msg_handle) t = size; s = 0; s = read(fd, option+s, t); - if (s <= 0) + if (s <= 0) { + free(option); goto out; + } t -= s; s = size - t; } while (t); -- 2.44.0