检查索引,否则数组越界
This commit is contained in:
parent
3005e494ae
commit
974d5bf93f
|
@ -41,7 +41,7 @@ void Setup(ushort code, const char* name, COM_Def message, int baudRate)
|
|||
}
|
||||
sp->Register(OnSerial);
|
||||
|
||||
WatchDog::Start(20000);
|
||||
//WatchDog::Start(20000);
|
||||
#else
|
||||
WatchDog::Start();
|
||||
#endif
|
||||
|
|
|
@ -274,6 +274,7 @@ bool TinyClient::Report(uint offset, const ByteArray& bs)
|
|||
void TinyClient::ReportAsync(uint offset)
|
||||
{
|
||||
if(this == NULL) return;
|
||||
if(offset >= Store.Data.Length()) return;
|
||||
|
||||
NextReport = offset;
|
||||
|
||||
|
@ -292,7 +293,9 @@ void TinyClientTask(void* param)
|
|||
assert_param2(offset == 0 || offset < 0x10, "自动上报偏移量异常!");
|
||||
if(offset)
|
||||
{
|
||||
client->Report(offset, client->Store.Data[offset]);
|
||||
// 检查索引,否则数组越界
|
||||
ByteArray& bs = client->Store.Data;
|
||||
if(bs.Length() > offset) client->Report(offset, bs[offset]);
|
||||
client->NextReport = 0;
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue