Blob Blame History Raw
From d725a138c5c311ba06567d6841933aa5b7b6a435 Mon Sep 17 00:00:00 2001
From: Thomas Hindoe Paaboel Andersen <phomes@gmail.com>
Date: Thu, 11 Sep 2014 23:41:44 +0200
Subject: [PATCH] analyze: avoid a null dereference

If we have an error in the early sd_bus_* calls then unit_times
will still be null.

Found with coverity. Fixes: CID#996464
---
 src/analyze/analyze.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c
index d860a022b7..1281d6b9ea 100644
--- a/src/analyze/analyze.c
+++ b/src/analyze/analyze.c
@@ -277,7 +277,8 @@ static int acquire_time_data(sd_bus *bus, struct unit_times **out) {
         return c;
 
 fail:
-        free_unit_times(unit_times, (unsigned) c);
+        if (unit_times)
+                free_unit_times(unit_times, (unsigned) c);
         return r;
 }