ESPAsyncWebServer icon indicating copy to clipboard operation
ESPAsyncWebServer copied to clipboard

Incorrect deletion of an item from LinkedList

Open dmitriy131313 opened this issue 2 years ago • 1 comments

In the method "_removeNotInterestingHeaders()" from "WebRequest.cpp " when deleting an element during the execution of the range base loop after a subsequent iteration, the pointer to _node in the nested class "Iterator" becomes incorrect, thus, after executing the overloaded operator "++" and subsequent calls to the element _node leads to undefined behavior.

dmitriy131313 avatar May 20 '23 04:05 dmitriy131313

I have come across a similar problem using the port for the Teensy 4.1. I had the same problem as the OP which I got around by requesting that all headers are interesting by adding the following code to canHandle.

request->addInterestingHeader("ANY");

I then also came across the problem again which I am still investigating which uses the same StringArray library for buffers for websockets. In the call to AsyncWebSocket::_cleanBuffers(), once one buffer is removed using _remove, the iterator class becomes corrupted and goes past the end of the linked list and presents invalid objects. This is where I think the problem is.

CrusaderElectronics avatar May 30 '23 14:05 CrusaderElectronics