chiark / gitweb /
analyze: avoid a null dereference
authorThomas Hindoe Paaboel Andersen <phomes@gmail.com>
Thu, 11 Sep 2014 21:41:44 +0000 (23:41 +0200)
committerThomas Hindoe Paaboel Andersen <phomes@gmail.com>
Thu, 11 Sep 2014 21:45:36 +0000 (23:45 +0200)
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

index d860a022b79b487b2a70b2036874951762da2a2c..1281d6b9ea835dfaae5ccf1a6a40bc6a059687f5 100644 (file)
@@ -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;
 }