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 @@ -179,8 +179,17 @@ void AsyncWebServerRequest::_onData(void *buf, size_t len){
179
179
}
180
180
181
181
void AsyncWebServerRequest::_removeNotInterestingHeaders (){
182
- if (_interestingHeaders.containsIgnoreCase (" ANY" )) return ; // nothing to do
183
- for (const auto & header: _headers){
182
+ if (_interestingHeaders.containsIgnoreCase (" ANY" )) {
183
+ return ; // nothing to do
184
+ }
185
+ // When removing items from the list, we must increase the iterator first
186
+ // before removing the current item, otherwise the iterator is invalidated
187
+ // So, no for(;;) loop can be used, see: https://stackoverflow.com/q/596162
188
+ auto i_header = _headers.begin ();
189
+ const auto i_end = _headers.end ();
190
+ while (i_header != i_end){
191
+ const auto header = *i_header;
192
+ ++i_header;
184
193
if (!_interestingHeaders.containsIgnoreCase (header->name ().c_str ())){
185
194
_headers.remove (header);
186
195
}
You can’t perform that action at this time.
0 commit comments