Fix time's conditional use of global_core to find its offset

Running a binary with no shared memory file created now correctly prints
out a useful error instead of segfaulting in time.

Change-Id: I99ea352c9676b90253719a4136b8c080e66778eb
diff --git a/aos/common/time.cc b/aos/common/time.cc
index 7318afb..d1985b5 100644
--- a/aos/common/time.cc
+++ b/aos/common/time.cc
@@ -38,7 +38,8 @@
          static_cast<uintmax_t>(clock), &temp);
   }
 
-  const timespec offset = (global_core == nullptr)
+  const timespec offset = (&global_core == nullptr || global_core == nullptr ||
+                           global_core->mem_struct == nullptr)
                               ? timespec{0, 0}
                               : global_core->mem_struct->time_offset;
   return Time(temp) + Time(offset);
@@ -223,7 +224,9 @@
 }
 
 void OffsetToNow(const Time &now) {
+  CHECK_NOTNULL(&global_core);
   CHECK_NOTNULL(global_core);
+  CHECK_NOTNULL(global_core->mem_struct);
   global_core->mem_struct->time_offset.tv_nsec = 0;
   global_core->mem_struct->time_offset.tv_sec = 0;
   global_core->mem_struct->time_offset = (now - Time::Now()).ToTimespec();