]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
log-context: Don't add log context if value is NULL 39608/head
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 5 Nov 2025 22:45:30 +0000 (23:45 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 14 Nov 2025 10:38:59 +0000 (11:38 +0100)
This avoids if conditions at the callsite which mess up stack based
lifetimes.

src/basic/log-context.c

index 27bce6f1f61044fa06ba99271ca3a68a8c8c7ff2..334fe95fc34581f24913a58d0a48a7087e1d8fde 100644 (file)
@@ -58,7 +58,9 @@ static LogContext* log_context_detach(LogContext *c) {
 LogContext* log_context_new(const char *key, const char *value) {
         assert(key);
         assert(endswith(key, "="));
-        assert(value);
+
+        if (!value)
+                return NULL;
 
         LIST_FOREACH(ll, i, _log_context)
                 if (i->key == key && i->value == value)