Fix nil pointer exception

This commit is contained in:
Neil Alexander 2020-03-20 10:42:11 +00:00
parent 139904f604
commit c1c81afbf6
3 changed files with 4 additions and 4 deletions

View file

@ -239,7 +239,7 @@ func (r joinRoomReq) joinRoomUsingServers(
return jsonerror.InternalServerError() return jsonerror.InternalServerError()
} }
var queryRes roomserverAPI.QueryLatestEventsAndStateResponse queryRes := roomserverAPI.QueryLatestEventsAndStateResponse{}
event, err := common.BuildEvent(r.req.Context(), &eb, r.cfg, r.evTime, r.queryAPI, &queryRes) event, err := common.BuildEvent(r.req.Context(), &eb, r.cfg, r.evTime, r.queryAPI, &queryRes)
if err == nil { if err == nil {
if _, err = r.producer.SendEvents(r.req.Context(), []gomatrixserverlib.Event{*event}, r.cfg.Matrix.ServerName, nil); err != nil { if _, err = r.producer.SendEvents(r.req.Context(), []gomatrixserverlib.Event{*event}, r.cfg.Matrix.ServerName, nil); err != nil {

View file

@ -353,8 +353,8 @@ func emit3PIDInviteEvent(
return err return err
} }
var queryRes *api.QueryLatestEventsAndStateResponse queryRes := api.QueryLatestEventsAndStateResponse{}
event, err := common.BuildEvent(ctx, builder, cfg, evTime, queryAPI, queryRes) event, err := common.BuildEvent(ctx, builder, cfg, evTime, queryAPI, &queryRes)
if err != nil { if err != nil {
return err return err
} }

View file

@ -76,7 +76,7 @@ func AddPrevEventsToEvent(
StateToFetch: eventsNeeded.Tuples(), StateToFetch: eventsNeeded.Tuples(),
} }
if queryRes == nil { if queryRes == nil {
*queryRes = api.QueryLatestEventsAndStateResponse{} queryRes = &api.QueryLatestEventsAndStateResponse{}
} }
if err = queryAPI.QueryLatestEventsAndState(ctx, &queryReq, queryRes); err != nil { if err = queryAPI.QueryLatestEventsAndState(ctx, &queryReq, queryRes); err != nil {
return err return err