[LoRaWAN] Fixed memory leak in downlink
This commit is contained in:
parent
a23d85c196
commit
2638fd0ad0
1 changed files with 9 additions and 0 deletions
|
@ -695,6 +695,9 @@ int16_t LoRaWANNode::downlink(uint8_t* data, size_t* len) {
|
||||||
|
|
||||||
// check the MIC
|
// check the MIC
|
||||||
if(!verifyMIC(downlinkMsg, RADIOLIB_AES128_BLOCK_SIZE + downlinkMsgLen, this->sNwkSIntKey)) {
|
if(!verifyMIC(downlinkMsg, RADIOLIB_AES128_BLOCK_SIZE + downlinkMsgLen, this->sNwkSIntKey)) {
|
||||||
|
#if !defined(RADIOLIB_STATIC_ONLY)
|
||||||
|
delete[] downlinkMsg;
|
||||||
|
#endif
|
||||||
return(RADIOLIB_ERR_CRC_MISMATCH);
|
return(RADIOLIB_ERR_CRC_MISMATCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -702,6 +705,9 @@ int16_t LoRaWANNode::downlink(uint8_t* data, size_t* len) {
|
||||||
uint32_t addr = LoRaWANNode::ntoh<uint32_t>(&downlinkMsg[RADIOLIB_LORAWAN_FHDR_DEV_ADDR_POS]);
|
uint32_t addr = LoRaWANNode::ntoh<uint32_t>(&downlinkMsg[RADIOLIB_LORAWAN_FHDR_DEV_ADDR_POS]);
|
||||||
if(addr != this->devAddr) {
|
if(addr != this->devAddr) {
|
||||||
RADIOLIB_DEBUG_PRINTLN("Device address mismatch, expected 0x%08X, got 0x%08X", this->devAddr, addr);
|
RADIOLIB_DEBUG_PRINTLN("Device address mismatch, expected 0x%08X, got 0x%08X", this->devAddr, addr);
|
||||||
|
#if !defined(RADIOLIB_STATIC_ONLY)
|
||||||
|
delete[] downlinkMsg;
|
||||||
|
#endif
|
||||||
return(RADIOLIB_ERR_DOWNLINK_MALFORMED);
|
return(RADIOLIB_ERR_DOWNLINK_MALFORMED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -745,6 +751,9 @@ int16_t LoRaWANNode::downlink(uint8_t* data, size_t* len) {
|
||||||
if(payLen <= 0) {
|
if(payLen <= 0) {
|
||||||
// no payload
|
// no payload
|
||||||
*len = 0;
|
*len = 0;
|
||||||
|
#if !defined(RADIOLIB_STATIC_ONLY)
|
||||||
|
delete[] downlinkMsg;
|
||||||
|
#endif
|
||||||
return(RADIOLIB_ERR_NONE);
|
return(RADIOLIB_ERR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue