* [PATCH] tools: Fix memory leak
@ 2014-09-16 14:03 Andrei Emeltchenko
2014-09-16 19:16 ` Johan Hedberg
0 siblings, 1 reply; 2+ messages in thread
From: Andrei Emeltchenko @ 2014-09-16 14:03 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Simplify code and fix memory leaks
---
tools/btgatt-client.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/tools/btgatt-client.c b/tools/btgatt-client.c
index f628bbb..41b85ad 100644
--- a/tools/btgatt-client.c
+++ b/tools/btgatt-client.c
@@ -539,8 +539,7 @@ static void cmd_write_value(struct client *cli, char *cmd_str)
if (strlen(argv[i]) != 2) {
printf("Invalid value byte: %s\n",
argv[i]);
- free(value);
- return;
+ goto done;
}
value[i-1] = strtol(argv[i], &endptr, 16);
@@ -548,8 +547,7 @@ static void cmd_write_value(struct client *cli, char *cmd_str)
|| errno == ERANGE) {
printf("Invalid value byte: %s\n",
argv[i]);
- free(value);
- return;
+ goto done;
}
}
}
@@ -559,11 +557,11 @@ static void cmd_write_value(struct client *cli, char *cmd_str)
false, value, length)) {
printf("Failed to initiate write without response "
"procedure\n");
- return;
+ goto done;
}
printf("Write command sent\n");
- return;
+ goto done;
}
if (!bt_gatt_client_write_value(cli->gatt, handle, value, length,
@@ -571,6 +569,7 @@ static void cmd_write_value(struct client *cli, char *cmd_str)
NULL, NULL))
printf("Failed to initiate write procedure\n");
+done:
free(value);
}
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] tools: Fix memory leak
2014-09-16 14:03 [PATCH] tools: Fix memory leak Andrei Emeltchenko
@ 2014-09-16 19:16 ` Johan Hedberg
0 siblings, 0 replies; 2+ messages in thread
From: Johan Hedberg @ 2014-09-16 19:16 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth
Hi Andrei,
On Tue, Sep 16, 2014, Andrei Emeltchenko wrote:
> Simplify code and fix memory leaks
> ---
> tools/btgatt-client.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
Applied. Thanks.
Johan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-09-16 19:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-16 14:03 [PATCH] tools: Fix memory leak Andrei Emeltchenko
2014-09-16 19:16 ` Johan Hedberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).