Try fixing a crash due to NULL derefence (#77)

* fix crash due to NULL _sendBuffer

Co-authored-by: etrinh <etrinh@zdionline.net>
This commit is contained in:
etrinh 2020-07-19 13:37:42 +02:00 committed by GitHub
parent ffea53614b
commit 52d3866e41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -2,6 +2,10 @@
#include <string.h>
#include "bits.h"
#ifndef KNX_FLASH_SIZE
# define KNX_FLASH_SIZE 8192
#endif
Memory::Memory(Platform& platform, DeviceObject& deviceObject)
: _platform(platform), _deviceObject(deviceObject)
{
@ -13,7 +17,7 @@ void Memory::readMemory()
if (_data != nullptr)
return;
uint16_t flashSize = 8192;
uint16_t flashSize = KNX_FLASH_SIZE;
_data = _platform.getEepromBuffer(flashSize);
printHex("RESTORED ", _data, _metadataSize);

View File

@ -245,7 +245,7 @@ void TpUartDataLinkLayer::loop()
//Destination Address + payload available
_xorSum ^= rxByte;
//check if echo
if (!((buffer[0] ^ _sendBuffer[0]) & ~0x20) && !memcmp(buffer + _convert + 1, _sendBuffer + 1, 5))
if (_sendBuffer != nullptr && (!((buffer[0] ^ _sendBuffer[0]) & ~0x20) && !memcmp(buffer + _convert + 1, _sendBuffer + 1, 5)))
{ //ignore repeated bit of control byte
_isEcho = true;
}