[WiFi] Fix crash when deleting element from empty list

Erase from a list from an element that does not exist may cause strange crashes when it is deleted either using `pop_front()`, `pop_back()` or `erase()`.
This commit is contained in:
TD-er
2021-02-12 10:36:53 +01:00
parent 97b9128da9
commit 6a082ffa31
2 changed files with 4 additions and 2 deletions
+1 -1
View File
@@ -119,7 +119,7 @@ void process_serialWriteBuffer() {
if (snip < bytes_to_write) { bytes_to_write = snip; }
while (bytes_to_write > 0) {
while (bytes_to_write > 0 && !serialWriteBuffer.empty()) {
const char c = serialWriteBuffer.front();
Serial.write(c);
serialWriteBuffer.pop_front();
+3 -1
View File
@@ -105,7 +105,9 @@ bool WiFi_AP_CandidatesList::getNext() {
if (mustPop) {
known_it = known.begin();
candidates.pop_front();
if (!candidates.empty()) {
candidates.pop_front();
}
}
return true;
}