From 0c892d59fa5846097647d08244059de4f73e39a6 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Mon, 11 May 2020 18:21:25 +0100 Subject: [PATCH] Prevent panic in membership updater (#1021) --- roomserver/internal/input_membership.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/roomserver/internal/input_membership.go b/roomserver/internal/input_membership.go index cba75b4f..19b7d805 100644 --- a/roomserver/internal/input_membership.go +++ b/roomserver/internal/input_membership.go @@ -16,6 +16,7 @@ package internal import ( "context" + "errors" "fmt" "github.com/matrix-org/dendrite/roomserver/api" @@ -106,6 +107,13 @@ func updateMembership( return updates, nil } + if add == nil { + // This shouldn't happen. Returning an error here is better than panicking + // in the membership updater functions later on. + // TODO: Why does this happen to begin with? + return updates, errors.New("add should not be nil") + } + mu, err := updater.MembershipUpdater(targetUserNID) if err != nil { return nil, err