Part Number:SIMPLELINK-CC2640R2-SDK
Hi
The Host_Test example in the latest version of the SIMPLELINK-CC2640R2-SDK fails due to corrupted memory when it tries to receive data from a subscribed characteristic if the data sent back is close to 255 bytes long. This is due to a bug in icall_hci_tl.c in the SDK. The bug happens because after adding the size of the header, it overflows an uint8_t totalLength varialbe and allocates an amount of memory far too small. E.g. Instead of allocating 258 bytes of memory, it allocates 3 bytes then stores the data, which later gets destroyed by allocating that space to something else. This is the offending code in icall_hci_tl.c :
uint8_t totalLength; // OSAL message header + HCI event header + data totalLength = sizeof(hciPacket_t) + HCI_EVENT_MIN_LENGTH + dataLen; // allocate memory for OSAL hdr + packet msg = (hciPacket_t *)ICall_allocMsg(totalLength);
To fix this simply increase the size of totalLength to be a uint16_t instead, i.e:
uint16_t totalLength; // OSAL message header + HCI event header + data totalLength = sizeof(hciPacket_t) + HCI_EVENT_MIN_LENGTH + dataLen; // allocate memory for OSAL hdr + packet msg = (hciPacket_t *)ICall_allocMsg(totalLength);
Please can you put this fix into the SDK,
Thanks very much,
Dan