From be2ae27af65e041d7149ae54b3dd3fbc8bbd83ac Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Tue, 17 Sep 2019 18:17:28 -0700 Subject: [PATCH] modules/client/sync/rooms/timeline: Fix loop conditions. --- modules/client/sync/rooms/timeline.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/modules/client/sync/rooms/timeline.cc b/modules/client/sync/rooms/timeline.cc index c51c785d7..3ab531df9 100644 --- a/modules/client/sync/rooms/timeline.cc +++ b/modules/client/sync/rooms/timeline.cc @@ -272,12 +272,15 @@ ircd::m::sync::_room_timeline_polylog_events(data &data, ++i; } - limited = i >= limit; - if(i > 0 && !it) + limited = i > limit; + if(i > 1 && !it) it.seek(event_idx); - if(i > 0) - for(++it; it && i > -1; ++it, --i) + if(i > 1 && it) + --i, ++it; + + if(i > 0 && it) + for(++it; i > 0 && it; --i, ++it) { const m::event &event {