Skip to content

Fix getNextNonEmptyFolder crash - #2123

Open
yunusey wants to merge 1 commit into
samuelclay:mainfrom
yunusey:fix-android-crash
Open

Fix getNextNonEmptyFolder crash#2123
yunusey wants to merge 1 commit into
samuelclay:mainfrom
yunusey:fix-android-crash

Conversation

@yunusey

@yunusey yunusey commented Aug 1, 2026

Copy link
Copy Markdown

Thanks for making NewsBlur!

A couple of hours ago I hit a crash on my Android phone.

NewsBlur-Crash-Logs.txt

I was going to open an issue, but the crash looked fun (stack overflows are everyone's favorite after all!), so I figured I'd try fixing it myself. Note: I know pretty much no Kotlin.

The production trace is obfuscated, so I built a debug APK and reproduced it on Waydroid. A few log statements later, the bug showed up in getNextNonEmptyFolder.

When no folder has any unread feeds under the current filter, that function never stops walking the folder list. It wraps forever and eventually blows the stack.

The fix keeps the public shape the same: the original function now calls an overload that also takes startFolderName. It still walks the folders, but once it comes back around to the folder it started from, it returns null. I also added a unit test that used to throw a StackOverflowError before this change.

I tried to keep the patch small. Longer term, I'd personally drop the recursion here. I'm not deep enough in Kotlin to speak to every language-level detail, but from a normal programming point of view this burns stack for no real benefit, I believe. A plain loop would be clearer and safer.

@yunusey
yunusey force-pushed the fix-android-crash branch from c5caad8 to c569c4d Compare August 1, 2026 05:32
@yunusey
yunusey force-pushed the fix-android-crash branch from c569c4d to 4e20342 Compare August 1, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant