chiark / gitweb /
timedatectl: properly initialize struct before decoding bus messages
[elogind.git] / src / timedate / timedatectl.c
index 8c6e7c9212100e2651ec28e49336e5537b733129..e94a847bf1be8d16410ad5412648978cbe8ff560 100644 (file)
@@ -69,11 +69,9 @@ typedef struct StatusInfo {
 } StatusInfo;
 
 static bool ntp_synced(void) {
-
         struct timex txc;
 
         zero(txc);
-
         if (adjtimex(&txc) < 0)
                 return false;
 
@@ -90,6 +88,8 @@ static void print_status_info(StatusInfo *i) {
         time_t sec;
         int r;
 
+        assert(i);
+
         n = now(CLOCK_REALTIME);
         sec = (time_t) (n / USEC_PER_SEC);
 
@@ -191,6 +191,7 @@ static int show_status(DBusConnection *bus, char **args, unsigned n) {
                 return -EIO;
         }
 
+        zero(info);
         dbus_message_iter_recurse(&iter, &sub);
 
         while (dbus_message_iter_get_arg_type(&sub) != DBUS_TYPE_INVALID) {