From 2fe6df89fbd585437817cf0fcc346b5afd5d9b97 Mon Sep 17 00:00:00 2001 From: elliothllm <143621200+elliothllm@users.noreply.github.com> Date: Wed, 5 Feb 2025 19:25:57 +0000 Subject: [PATCH] fix(safe-client): check safe client for nil (#154) --- datastreamer/streamserver.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/datastreamer/streamserver.go b/datastreamer/streamserver.go index 6816fb8..cf8256b 100644 --- a/datastreamer/streamserver.go +++ b/datastreamer/streamserver.go @@ -336,9 +336,17 @@ func (s *StreamServer) handleConnection(conn net.Conn) { return } + // Check if the client is nil + safeClient := s.getSafeClient(clientID) + if safeClient == nil { + log.Errorf("Client %s is nil", clientID) + s.killClient(clientID) + return + } + // Manage the requested command log.Debugf("Command %d[%s] received from %s", command, StrCommand[Command(command)], clientID) - err = s.processCommand(Command(command), s.getSafeClient(clientID)) + err = s.processCommand(Command(command), safeClient) if err != nil { log.Errorf("Error processing command %d[%s] from %s: %v", command, StrCommand[Command(command)], clientID, err) }