Skip to content

Node.js based forum software built for the modern web

fix: #12502, improper decrement

Julian Lam6befff5e11b3
diff --git a/src/topics/index.js b/src/topics/index.js
index 77573a2154..990d101988 100644
--- a/src/topics/index.js
+++ b/src/topics/index.js
@@ -316,7 +316,7 @@ Topics.search = async function (tid, term) {
Topics.getPidByIndex = async function (tid, index) {
index -= 2; // zset only stores replies, index is not zero-indexed, so offset by 2.
return index > 0 ?
- (await db.getSortedSetRange(`tid:${tid}:posts`, index - 2, index - 2)).pop() :
+ (await db.getSortedSetRange(`tid:${tid}:posts`, index, index)).pop() :
await Topics.getTopicField(tid, 'mainPid');
};