Skip to content

Commit d9d8b4d

Browse files
committed
Merge branch 'ul-gh-fix_837' into yuboxfixes
2 parents 334959e + 1178428 commit d9d8b4d

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/WebRequest.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,17 @@ void AsyncWebServerRequest::_onData(void *buf, size_t len){
182182
}
183183

184184
void AsyncWebServerRequest::_removeNotInterestingHeaders(){
185-
if (_interestingHeaders.containsIgnoreCase(F("ANY"))) return; // nothing to do
186-
for(const auto& header: _headers){
185+
if (_interestingHeaders.containsIgnoreCase(F("ANY"))) {
186+
return; // nothing to do
187+
}
188+
// When removing items from the list, we must increase the iterator first
189+
// before removing the current item, otherwise the iterator is invalidated
190+
// So, no for(;;) loop can be used, see: https://stackoverflow.com/q/596162
191+
auto i_header = _headers.begin();
192+
const auto i_end = _headers.end();
193+
while (i_header != i_end){
194+
const auto header = *i_header;
195+
++i_header;
187196
if(!_interestingHeaders.containsIgnoreCase(header->name().c_str())){
188197
_headers.remove(header);
189198
}

0 commit comments

Comments
 (0)