Fixed Bug in TimedWrites
The loop over TimedWrites incorrectly erased iterators inside a for-loop. For some reason this never caused an issue on the ESP32, but crashed on the ESP32-C3. Solution is to change the for-loop to a while-loop with proper handling of the iterator when an element is deleted. This appears to fix the problem.
This commit is contained in:
parent
a8e6e643f9
commit
d8bb51902f
|
|
@ -1286,13 +1286,17 @@ void HAPClient::checkTimedWrites(){
|
|||
|
||||
char c[64];
|
||||
|
||||
for(auto tw=homeSpan.TimedWrites.begin(); tw!=homeSpan.TimedWrites.end(); tw++){ // loop over all Timed Writes using an iterator
|
||||
auto tw=homeSpan.TimedWrites.begin();
|
||||
while(tw!=homeSpan.TimedWrites.end()){
|
||||
if(cTime>tw->second){ // timer has expired
|
||||
sprintf(c,"Removing PID=%llu ALARM=%u\n",tw->first,tw->second);
|
||||
LOG2(c);
|
||||
homeSpan.TimedWrites.erase(tw);
|
||||
tw=homeSpan.TimedWrites.erase(tw);
|
||||
}
|
||||
else
|
||||
tw++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
|
|
|
|||
Loading…
Reference in New Issue