From c02f1b026aa00b4f7ed18f71a7de9264fff35513 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 26 Feb 2015 14:48:56 +1100 Subject: [PATCH] add extra safety so offset can not be negative --- lib/topic_query.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/topic_query.rb b/lib/topic_query.rb index 15503dab1..8269050bf 100644 --- a/lib/topic_query.rb +++ b/lib/topic_query.rb @@ -170,7 +170,9 @@ class TopicQuery if page == 0 (pinned_topics + unpinned_topics)[0...limit] if limit else - unpinned_topics.offset((page * per_page - pinned_topics.count) - 1).to_a + offset = (page * per_page - pinned_topics.count) - 1 + offset = 0 unless offset > 0 + unpinned_topics.offset(offset).to_a end end