From 59a01e6803fa68bf964e1cc7cd6fef328d617d2a Mon Sep 17 00:00:00 2001 From: DashyFox Date: Fri, 16 Feb 2024 17:12:38 +0300 Subject: [PATCH] fix size arr --- IR_Decoder.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/IR_Decoder.h b/IR_Decoder.h index bcec29a..659515b 100644 --- a/IR_Decoder.h +++ b/IR_Decoder.h @@ -73,7 +73,7 @@ public: uint8_t _msgType = 0; uint16_t _addrFrom = 0; uint16_t _addrTo = 0; - uint8_t _data[bytePerPack]; + uint8_t _data[dataByteSizeMax]; uint8_t _dataRawSize = 0; uint16_t _crcPackVal = 0; uint16_t _crcCalcVal = 0; @@ -85,8 +85,8 @@ public: _dataRawSize = len; _err = err; _bitPeriod = rTime; - memset(_data, 0, bytePerPack); - for (uint8_t i = 0; i < len && len < bytePerPack; i++) { _data[i] = ptr[i]; } + memset(_data, 0, dataByteSizeMax); + memcpy(_data, ptr, min(len, dataByteSizeMax)); _msgType = _data[0]; ini(); _isAvaliable = true;