mirror of
https://github.com/me-no-dev/ESPAsyncWebServer.git
synced 2025-08-05 05:34:38 +02:00
Fix memory leak on successive call to setAuthentication
(as reported in https://github.com/tbnobody/OpenDTU/pull/2320)
This commit is contained in:
@@ -717,7 +717,8 @@ class AsyncWebRewrite {
|
|||||||
|
|
||||||
class AsyncWebHandler : public AsyncMiddlewareChain {
|
class AsyncWebHandler : public AsyncMiddlewareChain {
|
||||||
protected:
|
protected:
|
||||||
ArRequestFilterFunction _filter{nullptr};
|
ArRequestFilterFunction _filter = nullptr;
|
||||||
|
AuthenticationMiddleware* _authMiddleware = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AsyncWebHandler() {}
|
AsyncWebHandler() {}
|
||||||
|
@@ -28,13 +28,13 @@ AsyncWebHandler& AsyncWebHandler::setFilter(ArRequestFilterFunction fn) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
AsyncWebHandler& AsyncWebHandler::setAuthentication(const char* username, const char* password) {
|
AsyncWebHandler& AsyncWebHandler::setAuthentication(const char* username, const char* password) {
|
||||||
if (username == nullptr || password == nullptr || strlen(username) == 0 || strlen(password) == 0)
|
if (!_authMiddleware) {
|
||||||
return *this;
|
_authMiddleware = new AuthenticationMiddleware();
|
||||||
AuthenticationMiddleware* m = new AuthenticationMiddleware();
|
_authMiddleware->_freeOnRemoval = true;
|
||||||
m->setUsername(username);
|
addMiddleware(_authMiddleware);
|
||||||
m->setPassword(password);
|
}
|
||||||
m->_freeOnRemoval = true;
|
_authMiddleware->setUsername(username);
|
||||||
addMiddleware(m);
|
_authMiddleware->setPassword(password);
|
||||||
return *this;
|
return *this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user