I am getting the runtime error: index 1024 out of bounds for type 'uint8_t [1024]' during run time
at
EepromShadow[shadow_address] = TempRecord.Payload[index];
How to fix this out of bound issue?
Below is the code:
struct TEMP_RECORD
{
uint8_t Length;
uint32_t Address;
uint8_t Checksum;
uint8_t PayloadSize;
uint8_t Payload[S37_MAX_PAYLOAD_SIZE];
};
inline constexpr uint16_t MAX_EEPROM_SHADOW_ADDRESS = 1024;
uint8_t EepromShadow[MAX_EEPROM_SHADOW_ADDRESS];
TEMP_RECORD TempRecord;
for(uint32_t index = 0; index < TempRecord.PayloadSize; ++index)
{
uint32_t shadow_address = TempRecord.Address + index;
if (i < MAX_EEPROM_SHADOW_ADDRESS)
{
EepromShadow[shadow_address] = TempRecord.Payload[index];
}
}
Aucun commentaire:
Enregistrer un commentaire