Skip to content

Commit 44dabfb

Browse files
authored
Cordio BLE: Dynamically calculate message length (#385)
The vendor specific HCI event can contain messages of arbitrary length, thus the length of the message allocation must depend on the length of the event.
1 parent 99fcb5b commit 44dabfb

File tree

1 file changed

+3
-1
lines changed
  • connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/hci/dual_chip

1 file changed

+3
-1
lines changed

connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/hci/dual_chip/hci_evt.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2754,6 +2754,7 @@ void hciEvtProcessMsg(uint8_t *pEvt)
27542754
uint8_t evt;
27552755
uint8_t subEvt;
27562756
uint8_t len;
2757+
uint8_t extraMsgLen = 0;
27572758
uint8_t cbackEvt = 0;
27582759
hciEvt_t *pMsg;
27592760
uint16_t handle;
@@ -3013,6 +3014,7 @@ void hciEvtProcessMsg(uint8_t *pEvt)
30133014
#endif
30143015
hciEvtStats.numVendorSpecEvt++;
30153016
cbackEvt = HCI_VENDOR_SPEC_CBACK_EVT;
3017+
extraMsgLen = len;
30163018

30173019
#ifdef WSF_DETOKEN_TRACE
30183020
if (WsfDetokenProcessHciEvent(len, pEvt))
@@ -3030,7 +3032,7 @@ void hciEvtProcessMsg(uint8_t *pEvt)
30303032
if (cbackEvt != 0)
30313033
{
30323034
/* allocate temp buffer */
3033-
if ((pMsg = WsfBufAlloc(hciEvtCbackLen[cbackEvt])) != NULL)
3035+
if ((pMsg = WsfBufAlloc(hciEvtCbackLen[cbackEvt] + extraMsgLen)) != NULL)
30343036
{
30353037
/* initialize message header */
30363038
pMsg->hdr.param = 0;

0 commit comments

Comments
 (0)