diff options
author | 2022-09-26 08:39:59 +0100 | |
---|---|---|
committer | 2022-09-26 09:39:59 +0200 | |
commit | 82061b1202a81cef0bb4874e6a093cda56822f02 (patch) | |
tree | 922e6bc24311de0b29a285eecb4a5d3ef9468ed5 /internal/federation/dereferencing/thread.go | |
parent | [bugfix] update thread iterators to not use recursion (#851) (diff) | |
download | gotosocial-82061b1202a81cef0bb4874e6a093cda56822f02.tar.xz |
[bugfix] panic during child thread iteration (#852)
* *actually* start at top of stack loop on find remote child, fix iter indexing
Signed-off-by: kim <grufwub@gmail.com>
* add improved code comment
Signed-off-by: kim <grufwub@gmail.com>
Signed-off-by: kim <grufwub@gmail.com>
Diffstat (limited to 'internal/federation/dereferencing/thread.go')
-rw-r--r-- | internal/federation/dereferencing/thread.go | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/internal/federation/dereferencing/thread.go b/internal/federation/dereferencing/thread.go index d15f05964..7626454a6 100644 --- a/internal/federation/dereferencing/thread.go +++ b/internal/federation/dereferencing/thread.go @@ -235,11 +235,11 @@ stackLoop: // Start off the item iterator current.itemIter = items.Begin() - current.iterIdx = -1 + current.iterIdx = 0 } itemLoop: - for current.iterIdx++; current.iterIdx < current.iterLen; current.iterIdx++ { + for ; current.iterIdx < current.iterLen; current.iterIdx++ { var itemIRI *url.URL // Get next item iterator object @@ -275,11 +275,21 @@ stackLoop: continue itemLoop } + // Iter past this item. Normally this would be + // handled by the third clause of the itemLoop's + // embedded range checking, but at the bottom of this + // loop since we found a new status we circle back to + // the beginning of the stackLoop and skip iteration. + current.iterIdx++ + // Put current and next frame at top of stack stack = append(stack, current, &frame{ statusIRI: itemIRI, statusable: statusable, }) + + // Now start at top of loop + continue stackLoop } // Item iterator is done |