From b638b06ec13e9358c554d88cb60fa8c408944d95 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Wed, 28 Jul 2021 16:30:28 +0100 Subject: [PATCH] Allocate the maps first --- keyserver/internal/internal.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/keyserver/internal/internal.go b/keyserver/internal/internal.go index 75dd1661..34aa8afc 100644 --- a/keyserver/internal/internal.go +++ b/keyserver/internal/internal.go @@ -220,17 +220,18 @@ func (a *KeyInternalAPI) QueryDeviceMessages(ctx context.Context, req *api.Query } func (a *KeyInternalAPI) QueryKeys(ctx context.Context, req *api.QueryKeysRequest, res *api.QueryKeysResponse) { + res.DeviceKeys = make(map[string]map[string]json.RawMessage) + res.MasterKeys = make(map[string]gomatrixserverlib.CrossSigningKey) + res.SelfSigningKeys = make(map[string]gomatrixserverlib.CrossSigningKey) + res.UserSigningKeys = make(map[string]gomatrixserverlib.CrossSigningKey) + res.Failures = make(map[string]interface{}) + // get cross-signing keys from the database if err := a.crossSigningKeys(ctx, req, res); err != nil { // TODO: handle this util.GetLogger(ctx).WithError(err).Error("Failed to retrieve cross-signing keys") } - res.DeviceKeys = make(map[string]map[string]json.RawMessage) - res.MasterKeys = make(map[string]gomatrixserverlib.CrossSigningKey) - res.SelfSigningKeys = make(map[string]gomatrixserverlib.CrossSigningKey) - res.UserSigningKeys = make(map[string]gomatrixserverlib.CrossSigningKey) - res.Failures = make(map[string]interface{}) // make a map from domain to device keys domainToDeviceKeys := make(map[string]map[string][]string) for userID, deviceIDs := range req.UserToDevices {