check for nil body prior to unmarshal

This commit is contained in:
Maryum Styles 2019-10-22 23:35:25 -07:00
parent 145921f207
commit 3488b991d4

View file

@ -45,6 +45,12 @@ func SendMembership(
queryAPI roomserverAPI.RoomserverQueryAPI, asAPI appserviceAPI.AppServiceQueryAPI,
producer *producers.RoomserverProducer,
) util.JSONResponse {
if req.Body==nil {
return util.JSONResponse{
Code: http.StatusBadRequest,
JSON: jsonerror.NotJSON("Content is nil"),
}
}
var body threepid.MembershipRequest
if reqErr := httputil.UnmarshalJSONRequest(req, &body); reqErr != nil {
return *reqErr