From 77d439dddf70e5c65949f2099c19fb13f156430f Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Mon, 19 Jul 2021 10:21:25 +0100 Subject: [PATCH] Check for missing state keys to avoid panicking --- federationapi/routing/leave.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/federationapi/routing/leave.go b/federationapi/routing/leave.go index a5231004c..e31a32402 100644 --- a/federationapi/routing/leave.go +++ b/federationapi/routing/leave.go @@ -174,6 +174,13 @@ func SendLeave( } } + if event.StateKey() == nil { + return util.JSONResponse{ + Code: http.StatusBadRequest, + JSON: jsonerror.InvalidArgumentValue("missing state_key"), + } + } + // Check if the user has already left. If so, no-op! queryReq := &api.QueryLatestEventsAndStateRequest{ RoomID: roomID,