From 274db2fbaf5e79c63517e7f31068bbf626e567f1 Mon Sep 17 00:00:00 2001 From: Cnly Date: Thu, 27 Jun 2019 05:00:48 +0800 Subject: [PATCH] Fix zero value of currPos may be used in OnIncomingSyncRequest Signed-off-by: Alex Chen --- syncapi/sync/requestpool.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/syncapi/sync/requestpool.go b/syncapi/sync/requestpool.go index 1c91fa467..c7c024af6 100644 --- a/syncapi/sync/requestpool.go +++ b/syncapi/sync/requestpool.go @@ -63,9 +63,11 @@ func (rp *RequestPool) OnIncomingSyncRequest(req *http.Request, device *authtype "timeout": syncReq.timeout, }).Info("Incoming /sync request") + currPos := rp.notifier.CurrentPosition() + // If this is an initial sync or timeout=0 we return immediately if syncReq.since == nil || syncReq.timeout == 0 { - syncData, err = rp.currentSyncForUser(*syncReq, rp.notifier.CurrentPosition()) + syncData, err = rp.currentSyncForUser(*syncReq, currPos) if err != nil { return httputil.LogThenError(req, err) } @@ -90,7 +92,6 @@ func (rp *RequestPool) OnIncomingSyncRequest(req *http.Request, device *authtype // respond with, so we skip the return an go back to waiting for content to // be sent down or the request timing out. var hasTimedOut bool - var currPos types.SyncPosition sincePos := *syncReq.since for { select {