summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-01-30 11:55:21 +0100
committerAndreas Kling <kling@serenityos.org>2021-01-30 11:55:21 +0100
commit489d413fc7b6e401dae348625aa3f6a520aba0c5 (patch)
tree431a9f06f42c1a297ba969fc3a656cc4e2c431e8 /Userland
parent5cbc9d57246ce23083101c44ee8d0d427356e00e (diff)
downloadserenity-489d413fc7b6e401dae348625aa3f6a520aba0c5.zip
LookupServer: Be a little more robust in case accept() fails
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Services/LookupServer/LookupServer.cpp8
-rw-r--r--Userland/Services/LookupServer/LookupServer.h2
2 files changed, 6 insertions, 4 deletions
diff --git a/Userland/Services/LookupServer/LookupServer.cpp b/Userland/Services/LookupServer/LookupServer.cpp
index f2b1d29128..338f76034d 100644
--- a/Userland/Services/LookupServer/LookupServer.cpp
+++ b/Userland/Services/LookupServer/LookupServer.cpp
@@ -52,9 +52,11 @@ LookupServer::LookupServer()
m_local_server = Core::LocalServer::construct(this);
m_local_server->on_ready_to_accept = [this]() {
auto socket = m_local_server->accept();
+ if (!socket)
+ return;
socket->on_ready_to_read = [this, socket]() {
- service_client(socket);
- RefPtr<Core::LocalSocket> keeper = socket;
+ service_client(*socket);
+ NonnullRefPtr keeper = *socket;
const_cast<Core::LocalSocket&>(*socket).on_ready_to_read = [] {};
};
};
@@ -97,7 +99,7 @@ void LookupServer::load_etc_hosts()
}
}
-void LookupServer::service_client(RefPtr<Core::LocalSocket> socket)
+void LookupServer::service_client(NonnullRefPtr<Core::LocalSocket> socket)
{
u8 client_buffer[1024];
int nrecv = socket->read(client_buffer, sizeof(client_buffer) - 1);
diff --git a/Userland/Services/LookupServer/LookupServer.h b/Userland/Services/LookupServer/LookupServer.h
index aba488457b..b2ecf414cb 100644
--- a/Userland/Services/LookupServer/LookupServer.h
+++ b/Userland/Services/LookupServer/LookupServer.h
@@ -40,7 +40,7 @@ private:
LookupServer();
void load_etc_hosts();
- void service_client(RefPtr<Core::LocalSocket>);
+ void service_client(NonnullRefPtr<Core::LocalSocket>);
Vector<String> lookup(const String& hostname, const String& nameserver, bool& did_get_response, unsigned short record_type, ShouldRandomizeCase = ShouldRandomizeCase::Yes);
struct CachedLookup {