Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Bugfixes:
* Improved uptime detection on SunOS via kstat. (#2674, Uptime, SunOS)
* Fixed substring formatting returning the remaining string when a negative end index is before the start of the string. (General)
* Fixed an infinite loop when the separator string is empty. (#2689, Separator)

# 2.70.0

Expand Down
5 changes: 3 additions & 2 deletions src/modules/separator/separator.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ bool ffPrintSeparator(FFSeparatorOptions* options) {
} else {
uint32_t wcsLength = ffUtf8StrWidth(options->string.chars, options->string.length);

int remaining = (int) titleLength;
// An empty string can't fill the line: there is nothing to repeat
int remaining = wcsLength > 0 ? (int) titleLength : 0;
// Write the whole separator as often as it fits fully into titleLength
for (; remaining >= (int) wcsLength; remaining -= (int) wcsLength) {
for (; wcsLength > 0 && remaining >= (int) wcsLength; remaining -= (int) wcsLength) {
ffStrbufWriteTo(&options->string, stdout);
}

Expand Down