From 0eb6a265781a78823f16a050ff91ea7411165a70 Mon Sep 17 00:00:00 2001 From: Don Yin Date: Fri, 23 Oct 2026 12:44:55 +0100 Subject: [PATCH 1/2] Format: fix substring ends before the start of the string Closes #2668 Signed-off-by: Don Yin --- CHANGELOG.md | 1 + src/common/impl/format.c | 2 +- tests/format.c | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 61d12fc3ee..6d54b639d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ Features: * Added an ALSA fallback to Sound on Linux, so a machine that runs no sound server reports its output device and volume instead of an error. (Sound, Linux) Bugfixes: +* Fixed substring formatting returning the remaining string when a negative end index is before the start of the string. (General) * Fixed `--config`/`-c` bash completion offering one candidate per word instead of one candidate per file for paths containing spaces. (Completion, Bash) * Fixed external monitors detected via DDC/CI being randomly reported as built-in on Linux. (#2615, Brightness, Linux) * Fixed the Vulkan driver name being concatenated with the name of a previously enumerated device on multi-GPU systems. (#2619, Vulkan) diff --git a/src/common/impl/format.c b/src/common/impl/format.c index b3b8ab190d..6a9aa8c539 100644 --- a/src/common/impl/format.c +++ b/src/common/impl/format.c @@ -552,7 +552,7 @@ static bool parseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint3 if (end < 0) { end = (int32_t) tempString.length + end; } - if ((uint32_t) end > tempString.length) { + if (end >= 0 && (uint32_t) end > tempString.length) { end = (int32_t) tempString.length; } if (end > start) { diff --git a/tests/format.c b/tests/format.c index 374fd48dfe..0858c967bc 100644 --- a/tests/format.c +++ b/tests/format.c @@ -96,6 +96,7 @@ int main(void) { VERIFY("output({1~10,10})", "12345 67890", "output()"); VERIFY("output({1~10,5})", "12345 67890", "output()"); VERIFY("output({1~3,-3})", "12345 67890", "output(45 67)"); + VERIFY("output({1~0,-12})", "12345 67890", "output()"); VERIFY("output({1~-5,-3})", "12345 67890", "output(67)"); VERIFY("output({1~-0,10})", "12345 67890", "output(12345 6789)"); VERIFY("output({1~-3,-5})", "12345 67890", "output()"); From b4877683cf7a8a8cdc1216be0d2adfcebe8843b4 Mon Sep 17 00:00:00 2001 From: Don Yin Date: Sun, 25 Oct 2026 22:25:31 +0000 Subject: [PATCH 2/2] Doc: moves changelog entry to Unreleased [ci skip] I moved the unreleased fix out of the 2.70.0 section. Signed-off-by: Don Yin --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d54b639d3..1cee15ad96 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# Unreleased + +Bugfixes: +* Fixed substring formatting returning the remaining string when a negative end index is before the start of the string. (General) + # 2.70.0 Changes: @@ -27,7 +32,6 @@ Features: * Added an ALSA fallback to Sound on Linux, so a machine that runs no sound server reports its output device and volume instead of an error. (Sound, Linux) Bugfixes: -* Fixed substring formatting returning the remaining string when a negative end index is before the start of the string. (General) * Fixed `--config`/`-c` bash completion offering one candidate per word instead of one candidate per file for paths containing spaces. (Completion, Bash) * Fixed external monitors detected via DDC/CI being randomly reported as built-in on Linux. (#2615, Brightness, Linux) * Fixed the Vulkan driver name being concatenated with the name of a previously enumerated device on multi-GPU systems. (#2619, Vulkan)