Skip to content

Separator: fixes an infinite loop when the string is empty - #2690

Closed
arxhr007 wants to merge 1 commit into
fastfetch-cli:devfrom
arxhr007:fix/2689-separator-empty-string
Closed

arxhr007 wants to merge 1 commit into
fastfetch-cli:devfrom
arxhr007:fix/2689-separator-empty-string

Conversation

@arxhr007

Copy link
Copy Markdown

Summary

A separator module with an empty string made fastfetch loop forever. A string that is not a JSON string (a number, true, null, an array, an object) becomes empty too, so it hung the same way.

Related issue (required for new logos for new distros)

Fixes #2689

Changes

  • ffPrintSeparator: the string is repeated to fill the title width in a loop whose step is the string's display width. For an empty string that step is 0, so the loop never ended (and if it had, fwrite(options->string.chars, remaining, 1, stdout) below it would have read past the empty buffer). When the width is 0 nothing is repeated now: remaining starts at 0 and the loop is skipped.
  • CHANGELOG.md entry under Bugfixes.

Tested with { "modules": [ { "type": "separator", "string": "" } ] }, "string": 5 and "string": [1]: they hang before and print an empty separator line after, exit 0. "-", "=-", "日本" and "times": 5 print exactly the same bytes as before. Checked with a normal build and an ASan/UBSan build: no sanitizer messages. I did not add a test: the tests/ executables cover common/, not modules.

Screenshots

Not a visual change.

Checklist

  • I have tested my changes locally.

CarterLi added a commit that referenced this pull request Oct 30, 2026
@CarterLi

Copy link
Copy Markdown
Member

Fixed in another way

@CarterLi CarterLi closed this Oct 30, 2026
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.

[BUG] Separator module hangs when its string is empty

2 participants