From: Lennart Poettering Date: Mon, 20 Apr 2026 07:35:33 +0000 (+0200) Subject: sd-json: make sure SD_JSON_BUILD_STRING_UNDERSCORIFY() can deal with NULL strings X-Git-Tag: v260.2~214 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=29f4fba3c63341fcbfaa5152580e592c09470f47;p=thirdparty%2Fsystemd.git 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 a77a95665fba06861125a4a62ffed8ccd75f37f2) --- diff --git a/src/libsystemd/sd-json/sd-json.c b/src/libsystemd/sd-json/sd-json.c index e952d006ae5..f3beb92d180 100644 --- a/src/libsystemd/sd-json/sd-json.c +++ b/src/libsystemd/sd-json/sd-json.c @@ -3554,7 +3554,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 = strdup(p); if (!c) { r = -ENOMEM;