From fd61776f9312e31fadc8014fbf2323bed94aae91 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 18 Oct 2017 11:02:38 +0100 Subject: [PATCH] Fix off by one error --- src/github.com/matrix-org/dendrite/syncapi/sync/userstream.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/github.com/matrix-org/dendrite/syncapi/sync/userstream.go b/src/github.com/matrix-org/dendrite/syncapi/sync/userstream.go index a05b9e8fd..6dc1821c2 100644 --- a/src/github.com/matrix-org/dendrite/syncapi/sync/userstream.go +++ b/src/github.com/matrix-org/dendrite/syncapi/sync/userstream.go @@ -77,7 +77,7 @@ func (s *UserStream) Wait(ctx context.Context, waitAtPos types.StreamPosition) < // Icky but efficient way of filtering out the given channel for idx, ch := range s.waitingChannels { if posChannel == ch { - lastIdx := len(s.waitingChannels) + lastIdx := len(s.waitingChannels) - 1 s.waitingChannels[idx] = s.waitingChannels[lastIdx] s.waitingChannels[lastIdx] = nil // Ensure that the channel gets GCed s.waitingChannels = s.waitingChannels[:lastIdx]