From 21d4d3b7a7b2d410e24e4574adc17057b1996a9e Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Fri, 19 Dec 2014 14:30:28 +0200 Subject: [PATCH] android/gatt: Fix possible NULL dereference Fixes warnings: ... Pointer 'req' returned from call to function 'queue_peek_head' may be NULL and will be dereferenced ... --- android/gatt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/android/gatt.c b/android/gatt.c index fd9540087..9e0ee3f00 100644 --- a/android/gatt.c +++ b/android/gatt.c @@ -5588,6 +5588,9 @@ static void handle_server_send_response(const void *buf, uint16_t len) * gatt_db_attribute_write(). */ req = queue_peek_head(conn->device->pending_requests); + if (!req) + goto done; + /* Cast status to uint8_t, due to (byte) cast in java layer. */ req->error = err_to_att((uint8_t) cmd->status); req->state = REQUEST_DONE; -- 2.47.3