From 8d2cc1ff3dd11c9964fd626aae7a0d00037c1f27 Mon Sep 17 00:00:00 2001 From: Marcin Kraglak Date: Thu, 27 Mar 2014 22:13:01 +0100 Subject: [PATCH] android/gatt: Fix possible NULL pointer defererence If memory allocation failed, return error from handle_client_register. --- android/gatt.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/android/gatt.c b/android/gatt.c index 81bfdc05d..665cf0f74 100644 --- a/android/gatt.c +++ b/android/gatt.c @@ -234,6 +234,11 @@ static void handle_client_register(const void *buf, uint16_t len) } client = new0(struct gatt_client, 1); + if (!client) { + error("gatt: cannot allocate memory for registering client"); + status = HAL_STATUS_FAILED; + goto failed; + } memcpy(client->uuid, cmd->uuid, sizeof(client->uuid));