[PHY] Fix unknown string length buffer overrun (#413)

This commit is contained in:
jgromes 2021-11-29 08:05:46 +01:00
parent df466486aa
commit ffe271b0c6

View file

@ -107,7 +107,12 @@ int16_t PhysicalLayer::receive(String& str, size_t len) {
#if defined(RADIOLIB_STATIC_ONLY)
uint8_t data[RADIOLIB_STATIC_ARRAY_SIZE + 1];
#else
uint8_t* data = new uint8_t[length + 1];
uint8_t* data = NULL;
if(length == 0) {
data = new uint8_t[_maxPacketLength + 1];
} else {
data = new uint8_t[length + 1];
}
if(!data) {
return(RADIOLIB_ERR_MEMORY_ALLOCATION_FAILED);
}