Skip to content

Commit 0ff297c

Browse files
committed
Cordio BLE: Dynamically calculate message length
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 cda8a9d commit 0ff297c

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
@@ -2738,6 +2738,7 @@ void hciEvtProcessMsg(uint8_t *pEvt)
27382738
uint8_t evt;
27392739
uint8_t subEvt;
27402740
uint8_t len;
2741+
uint8_t extraMsgLen = 0;
27412742
uint8_t cbackEvt = 0;
27422743
hciEvt_t *pMsg;
27432744
uint16_t handle;
@@ -2997,6 +2998,7 @@ void hciEvtProcessMsg(uint8_t *pEvt)
29972998
#endif
29982999
hciEvtStats.numVendorSpecEvt++;
29993000
cbackEvt = HCI_VENDOR_SPEC_CBACK_EVT;
3001+
extraMsgLen = len;
30003002

30013003
#ifdef WSF_DETOKEN_TRACE
30023004
if (WsfDetokenProcessHciEvent(len, pEvt))
@@ -3014,7 +3016,7 @@ void hciEvtProcessMsg(uint8_t *pEvt)
30143016
if (cbackEvt != 0)
30153017
{
30163018
/* allocate temp buffer */
3017-
if ((pMsg = WsfBufAlloc(hciEvtCbackLen[cbackEvt])) != NULL)
3019+
if ((pMsg = WsfBufAlloc(hciEvtCbackLen[cbackEvt] + extraMsgLen)) != NULL)
30183020
{
30193021
/* initialize message header */
30203022
pMsg->hdr.param = 0;

0 commit comments

Comments
 (0)