File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -182,8 +182,17 @@ void AsyncWebServerRequest::_onData(void *buf, size_t len){
182
182
}
183
183
184
184
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;
187
196
if (!_interestingHeaders.containsIgnoreCase (header->name ().c_str ())){
188
197
_headers.remove (header);
189
198
}
You can’t perform that action at this time.
0 commit comments