ryantimwilson / rpms / systemd

Forked from rpms/systemd a month ago
Clone
9fc0f6
From 9765cfab7747c4d9435ec16a5fe29affeb2e52a7 Mon Sep 17 00:00:00 2001
9fc0f6
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
9fc0f6
Date: Sat, 12 Oct 2013 13:43:07 -0400
9fc0f6
Subject: [PATCH] Make sure that we don't dereference NULL
9fc0f6
9fc0f6
The code was actually safe, because b should
9fc0f6
never be null, because if rvalue is empty, a different
9fc0f6
branch is taken. But we *do* check for NULL in the
9fc0f6
loop above, so it's better to also check here for symmetry.
9fc0f6
---
9fc0f6
 src/core/load-fragment.c | 3 ++-
9fc0f6
 1 file changed, 2 insertions(+), 1 deletion(-)
9fc0f6
9fc0f6
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
9fc0f6
index 44920d6..f01843d 100644
9fc0f6
--- a/src/core/load-fragment.c
9fc0f6
+++ b/src/core/load-fragment.c
9fc0f6
@@ -1860,7 +1860,8 @@ int config_parse_documentation(const char *unit,
9fc0f6
                         free(*a);
9fc0f6
                 }
9fc0f6
         }
9fc0f6
-        *b = NULL;
9fc0f6
+        if (b)
9fc0f6
+                *b = NULL;
9fc0f6
 
9fc0f6
         return r;
9fc0f6
 }