Merge branch 'bugfix/protocomm_nimble_allocation_v4.3' into 'release/v4.3'

Fix for potential allocation bug in protocomm_nimble.c (v4.3)

See merge request espressif/esp-idf!15997
This commit is contained in:
Jiang Jiang Jian 2021-11-23 13:17:12 +00:00
commit 4cb5d9a5c8

View File

@ -325,6 +325,12 @@ gatt_svr_chr_access(uint16_t conn_handle, uint16_t attr_handle,
return rc == 0 ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES; return rc == 0 ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
case BLE_GATT_ACCESS_OP_WRITE_CHR: 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)); uuid = (uint8_t *) calloc(BLE_UUID128_VAL_LENGTH, sizeof(uint8_t));
if (!uuid) { if (!uuid) {
ESP_LOGE(TAG, "Error allocating memory for 128 bit UUID"); ESP_LOGE(TAG, "Error allocating memory for 128 bit UUID");