Skip to content

Commit

Permalink
Cordio BLE: Dynamically calculate message length
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Diff-fusion committed Nov 21, 2024
1 parent cda8a9d commit 0ff297c
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2738,6 +2738,7 @@ void hciEvtProcessMsg(uint8_t *pEvt)
uint8_t evt;
uint8_t subEvt;
uint8_t len;
uint8_t extraMsgLen = 0;
uint8_t cbackEvt = 0;
hciEvt_t *pMsg;
uint16_t handle;
Expand Down Expand Up @@ -2997,6 +2998,7 @@ void hciEvtProcessMsg(uint8_t *pEvt)
#endif
hciEvtStats.numVendorSpecEvt++;
cbackEvt = HCI_VENDOR_SPEC_CBACK_EVT;
extraMsgLen = len;

#ifdef WSF_DETOKEN_TRACE
if (WsfDetokenProcessHciEvent(len, pEvt))
Expand All @@ -3014,7 +3016,7 @@ void hciEvtProcessMsg(uint8_t *pEvt)
if (cbackEvt != 0)
{
/* allocate temp buffer */
if ((pMsg = WsfBufAlloc(hciEvtCbackLen[cbackEvt])) != NULL)
if ((pMsg = WsfBufAlloc(hciEvtCbackLen[cbackEvt] + extraMsgLen)) != NULL)
{
/* initialize message header */
pMsg->hdr.param = 0;
Expand Down

0 comments on commit 0ff297c

Please sign in to comment.