chiark / gitweb /
systemd-analyze: free unit_times only if it is not NULL
[elogind.git] / src / analyze / systemd-analyze.c
index 88fb40676e07c9bf97942fe9f8723d59aedc4f7b..7603cc0de4884022a335c7a2d6218769683ac886 100644 (file)
@@ -31,6 +31,7 @@
 #include "build.h"
 #include "util.h"
 #include "strxcpyx.h"
+#include "fileio.h"
 
 #define compare(a, b) (((a) > (b))? 1 : (((b) > (a))? -1 : 0))
 #define svg(...) printf(__VA_ARGS__)
@@ -236,9 +237,11 @@ static int acquire_time_data(DBusConnection *bus, struct unit_times **out)
         *out = unit_times;
         return c;
 fail:
-        for (; c >= 0; c--)
-                free(unit_times[c].name);
-        free(unit_times);
+        if (unit_times) {
+                for (; c >= 0; c--)
+                        free(unit_times[c].name);
+                free(unit_times);
+        }
         return r;
 }