[PATCH] android/tester-gatt.c:Fixed Memory leak

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch fixes memory leak issues in various functions
by allocating memory to  structure step only after intial
checks are performed as control was returning from these
checks without freeing memory allocated to it.
---
 android/tester-gatt.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/android/tester-gatt.c b/android/tester-gatt.c
index b8b088b..7083ac6 100644
--- a/android/tester-gatt.c
+++ b/android/tester-gatt.c
@@ -1140,13 +1140,15 @@ static void gatt_client_register_action(void)
 	struct test_data *data = tester_get_data();
 	struct step *current_data_step = queue_peek_head(data->steps);
 	bt_uuid_t *app_uuid = current_data_step->set_data;
-	struct step *step = g_new0(struct step, 1);
+	struct step *step;
 
 	if (!app_uuid) {
 		tester_warn("No app uuid provided for register action.");
 		return;
 	}
 
+	step = g_new0(struct step, 1);
+
 	step->action_status = data->if_gatt->client->register_client(app_uuid);
 
 	schedule_action_verification(step);
@@ -1392,13 +1394,15 @@ static void gatt_server_register_action(void)
 	struct test_data *data = tester_get_data();
 	struct step *current_data_step = queue_peek_head(data->steps);
 	bt_uuid_t *app_uuid = current_data_step->set_data;
-	struct step *step = g_new0(struct step, 1);
+	struct step *step;
 
 	if (!app_uuid) {
 		tester_warn("No app uuid provided for register action.");
 		return;
 	}
 
+	step = g_new0(struct step, 1);
+
 	step->action_status = data->if_gatt->server->register_server(app_uuid);
 
 	schedule_action_verification(step);
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux