Skip to content

Commit

Permalink
Cordio BLE: Dynamically calculate message length (#385)
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 authored Nov 23, 2024
1 parent 99fcb5b commit 44dabfb
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2754,6 +2754,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 @@ -3013,6 +3014,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 @@ -3030,7 +3032,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 44dabfb

Please sign in to comment.