From e0b7cdda80210e85cf663305433dda8f24e83c9a Mon Sep 17 00:00:00 2001 From: benyamin Date: Thu, 9 Nov 2023 15:42:23 +0330 Subject: [PATCH] fix nil pointer --- controllers/room.go | 4 ++++ repositories/room.go | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/controllers/room.go b/controllers/room.go index 62266bc..9cc21cc 100644 --- a/controllers/room.go +++ b/controllers/room.go @@ -89,6 +89,10 @@ func (c *RoomController) Offer(ctx *gin.Context) { c.helper.Response(ctx, struct{}{}, http.StatusNoContent) { ggid := c.repo.GetRoomGGID(reqModel.RoomId) + if ggid == nil { + println("ggid is nil, not answering for offer") + return + } buffer, err := json.Marshal(dto.SetSDPReqModel{ PeerDTO: dto.PeerDTO{ RoomId: reqModel.RoomId, diff --git a/repositories/room.go b/repositories/room.go index d869e36..54e2b7c 100644 --- a/repositories/room.go +++ b/repositories/room.go @@ -556,6 +556,11 @@ func (r *RoomRepository) offerPeer(peer *Peer, roomId string) error { return err } ggid := r.GetRoomGGID(roomId) + if ggid == nil { + println("[PC] ok not negotiating with peer", peer.ID, "(room is deleted)") + peer.HandshakeLock.Unlock() + return errors.New("room doesnt have ggid") + } reqModel := dto.SetSDPReqModel{ GGID: *ggid, PeerDTO: dto.PeerDTO{ -- 2.37.2