diff options
author | Ildar Kamaletdinov <i.kamaletdinov@omp.ru> | 2022-05-07 20:35:03 +0300 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2022-05-09 13:05:38 -0700 |
commit | a4741ef4bf6c6fb262b38a897312e929c2161cf9 (patch) | |
tree | 695e9d3de14084bb2f28d9bc8da715234a0af817 /tools/btgatt-client.c | |
parent | efa90050937c5eabc6c70a466bd886f164388484 (diff) | |
download | bluez-a4741ef4bf6c6fb262b38a897312e929c2161cf9.tar.gz |
tools: Fix memory leaks in btgatt-server/client
According to man buffer allocated by getline() should be freed by
the user program even if getline() failed.
Found by Linux Verification Center (linuxtesting.org) with the SVACE
static analysis tool.
Diffstat (limited to 'tools/btgatt-client.c')
-rw-r--r-- | tools/btgatt-client.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/tools/btgatt-client.c b/tools/btgatt-client.c index 8c9365aa2..58a03bd48 100644 --- a/tools/btgatt-client.c +++ b/tools/btgatt-client.c @@ -1355,12 +1355,16 @@ static void prompt_read_cb(int fd, uint32_t events, void *user_data) return; } - if ((read = getline(&line, &len, stdin)) == -1) + read = getline(&line, &len, stdin); + if (read < 0) { + free(line); return; + } if (read <= 1) { cmd_help(cli, NULL); print_prompt(); + free(line); return; } |