]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-json: make sure SD_JSON_BUILD_STRING_UNDERSCORIFY() can deal with NULL strings
authorLennart Poettering <lennart@amutable.com>
Mon, 20 Apr 2026 07:35:33 +0000 (09:35 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Fri, 22 May 2026 12:32:04 +0000 (13:32 +0100)
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)

src/libsystemd/sd-json/sd-json.c

index e952d006ae5c64435467c1304afd0e31735be5f6..f3beb92d180d26f50caf6fd9d662fe269a9864ac 100644 (file)
@@ -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;