Settings (FreeBSD): don't append trailing \0

This commit is contained in:
李通洲
2024-01-06 18:45:02 +08:00
parent b9777bec77
commit 0af40ab6a3
2 changed files with 3 additions and 3 deletions
+1
View File
@@ -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
+2 -3
View File
@@ -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