add nullptr protect

This commit is contained in:
DashyFox 2024-02-28 13:11:29 +03:00
parent f6bbd96a4c
commit cb1664bb4f

View File

@ -53,7 +53,7 @@ void IR_Encoder::sendData(uint16_t addrTo, uint8_t* data, uint8_t len, bool need
sendBuffer[3] = addrTo >> 8 & 0xFF;
sendBuffer[4] = addrTo & 0xFF;
for (uint16_t i = dataStart; i < dataStart + len; i++) {
for (uint16_t i = dataStart; (i < dataStart + len) && (data != nullptr); i++) {
sendBuffer[i] = ((uint8_t*)data)[i - dataStart];
}
@ -95,7 +95,7 @@ void IR_Encoder::sendAccept(uint16_t addrTo, uint8_t customByte = 0) {
}
void IR_Encoder::sendRequest(uint16_t addrTo) {
constexpr uint8_t packsize = msgBytes + addrBytes + addrBytes + crcBytes;
constexpr uint8_t packsize = msgBytes + addrBytes + addrBytes + crcBytes;
memset(sendBuffer, 0x00, dataByteSizeMax);
sendBuffer[0] = IR_MSG_REQUEST << 5;
sendBuffer[0] |= packsize & IR_MASK_MSG_INFO;