mirror of
https://github.com/Show-maket/IR-protocol.git
synced 2025-05-04 07:10:16 +00:00
add nullptr protect
This commit is contained in:
parent
f6bbd96a4c
commit
cb1664bb4f
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user