Merge pull request #14484 from kotcrab/http-crash

Fix crash in HTTPServer when processing invalid request
This commit is contained in:
Henrik Rydgård authored and GitHub committed 2021-05-27 15:48:22 +02:00
commit b10d90306f
1 file changed
+7 -1
+7 -1
View File
@@ -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()) {