diff options
author | Andrei Emeltchenko <andrei.emeltchenko@intel.com> | 2014-09-16 17:03:50 +0300 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2014-09-16 22:16:32 +0300 |
commit | 6616acfe8206ede4054b9be2a8821e6a8b59f7a0 (patch) | |
tree | 40cd8054dda877b6134a796953d4d6a234fa1275 /tools/btgatt-client.c | |
parent | a964070fdda42784078e43491df5367abc47fc14 (diff) | |
download | bluez-6616acfe8206ede4054b9be2a8821e6a8b59f7a0.tar.gz |
tools/btgatt-client: Fix memory leak
Simplify code and fix memory leaks
Diffstat (limited to 'tools/btgatt-client.c')
-rw-r--r-- | tools/btgatt-client.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/tools/btgatt-client.c b/tools/btgatt-client.c index f628bbb46..41b85ad33 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); } |