From 312506a41be70a9de3074bc579c9c61d5441111f Mon Sep 17 00:00:00 2001 From: kotcrab <4594081+kotcrab@users.noreply.github.com> Date: Thu, 27 May 2021 14:10:40 +0200 Subject: [PATCH] Fix crash in HTTPServer when processing invalid request --- Common/Net/HTTPServer.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Common/Net/HTTPServer.cpp b/Common/Net/HTTPServer.cpp index 882d49a965..c787c3f829 100644 --- a/Common/Net/HTTPServer.cpp +++ b/Common/Net/HTTPServer.cpp @@ -72,7 +72,9 @@ Request::Request(int fd) Request::~Request() { Close(); - _assert_(in_->Empty()); + if (!in_->Empty()) { + ERROR_LOG(IO, "Input not empty - invalid request?"); + } delete in_; if (!out_->Empty()) { ERROR_LOG(IO, "Output not empty - connection abort?"); @@ -330,6 +332,10 @@ void Server::HandleRequest(const Request &request) { } void Server::HandleRequestDefault(const Request &request) { + if (request.resource() == nullptr) { + fallback_(request); + return; + } // First, look through all handlers. If we got one, use it. auto handler = handlers_.find(request.resource()); if (handler != handlers_.end()) {