From 0af40ab6a3da282497bd374c006eba79b1b8ef72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 6 Jan 2024 18:45:02 +0800 Subject: [PATCH] Settings (FreeBSD): don't append trailing `\0` --- CHANGELOG.md | 1 + src/common/settings.c | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a1153a63..175bfc791 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ Features: Bugfixes: * Fix support of macOS Sonoma (Wallpaper, macOS) * Fix overall memory leaks (macOS) +* Remove trailing `\0` in JSON results (FreeBSD) # 2.5.0 diff --git a/src/common/settings.c b/src/common/settings.c index ae057a292..a01d4e706 100644 --- a/src/common/settings.c +++ b/src/common/settings.c @@ -411,9 +411,8 @@ bool ffSettingsGetFreeBSDKenv(const char* propName, FFstrbuf* result) //https://wiki.ghostbsd.org/index.php/Kenv ffStrbufEnsureFree(result, KENV_MVALLEN); int len = kenv(KENV_GET, propName, result->chars + result->length, KENV_MVALLEN); - if (len <= 0) return false; - result->length += (uint32_t) len; - result->chars[result->length] = '\0'; + if (len <= 1) return false; // number of bytes copied, including NUL terminator + result->length += (uint32_t) len - 1; return true; } #endif