From 3488b991d493b40693a31843346860d6a6d622b4 Mon Sep 17 00:00:00 2001 From: Maryum Styles Date: Tue, 22 Oct 2019 23:35:25 -0700 Subject: [PATCH] check for nil body prior to unmarshal --- clientapi/routing/membership.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/clientapi/routing/membership.go b/clientapi/routing/membership.go index c71ac2de2..c7494c3cf 100644 --- a/clientapi/routing/membership.go +++ b/clientapi/routing/membership.go @@ -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