sd-json: make sure SD_JSON_BUILD_STRING_UNDERSCORIFY() can deal with NULL strings

SD_JSON_BUILD_STRING() and everything else can deal with it, make sure
SD_JSON_BUILD_STRING_UNDERSCORIFY() can too.

(cherry picked from commit a77a95665f)
(cherry picked from commit 29f4fba3c6)
(cherry picked from commit a09efa6cf5)
This commit is contained in:
Lennart Poettering authored and Luca Boccassi committed 2026-05-27 15:29:27 +01:00
1 parent c76657a9bd
commit a7a252dc16
1 file changed
+1 -1
+1 -1
View File
@@ -3532,7 +3532,7 @@ _public_ int sd_json_buildv(sd_json_variant **ret, va_list ap) {
if (current->n_suppress == 0) {
_cleanup_free_ char *c = NULL;
if (command == _JSON_BUILD_STRING_UNDERSCORIFY) {
if (command == _JSON_BUILD_STRING_UNDERSCORIFY && p) {
c = strreplace(p, "-", "_");
if (!c) {
r = -ENOMEM;