From 5ba6ac26c4553b161367afc3514ad725804d169a Mon Sep 17 00:00:00 2001 From: isha pardikar Date: Tue, 26 Oct 2021 16:46:33 +0530 Subject: [PATCH] Merge branch 'bugfix/protocomm_nimble_allocation' into 'master' NimBLE: Fixed potential allocation bug in protocomm_nimble.c Closes https://github.com/espressif/esp-idf/issues/7689 See merge request espressif/esp-idf!15669 --- components/protocomm/src/transports/protocomm_nimble.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/protocomm/src/transports/protocomm_nimble.c b/components/protocomm/src/transports/protocomm_nimble.c index dd3fc25965..6bac49df39 100644 --- a/components/protocomm/src/transports/protocomm_nimble.c +++ b/components/protocomm/src/transports/protocomm_nimble.c @@ -319,6 +319,12 @@ gatt_svr_chr_access(uint16_t conn_handle, uint16_t attr_handle, return rc == 0 ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES; case BLE_GATT_ACCESS_OP_WRITE_CHR: + /* If empty packet is received, return */ + if (ctxt->om->om_len == 0) { + ESP_LOGD(TAG,"Empty packet"); + return 0; + } + uuid = (uint8_t *) calloc(BLE_UUID128_VAL_LENGTH, sizeof(uint8_t)); if (!uuid) { ESP_LOGE(TAG, "Error allocating memory for 128 bit UUID");