aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-07-19 11:36:43 +0200
committerNick Mathewson <nickm@torproject.org>2016-07-19 11:40:47 +0200
commit6ba415d4000712aecaf3d11903db5699f143569d (patch)
treee712ddefc86c914b5b4d9905ec411a44e1d5a6e2 /src/common
parent493142d91f7a553b26094308ebd2694dd30c3e0e (diff)
downloadtor-6ba415d4000712aecaf3d11903db5699f143569d.tar.gz
tor-6ba415d4000712aecaf3d11903db5699f143569d.zip
Make sure initialized_at is initialized before use.
Diffstat (limited to 'src/common')
-rw-r--r--src/common/compat_time.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/common/compat_time.c b/src/common/compat_time.c
index de3956685a..b7d69cf400 100644
--- a/src/common/compat_time.c
+++ b/src/common/compat_time.c
@@ -466,6 +466,10 @@ uint64_t
monotime_absolute_nsec(void)
{
monotime_t now;
+ if (BUG(monotime_initialized == 0)) {
+ monotime_init();
+ }
+
monotime_get(&now);
return monotime_diff_nsec(&initialized_at, &now);
}
@@ -486,6 +490,10 @@ monotime_absolute_msec(void)
uint64_t
monotime_coarse_absolute_nsec(void)
{
+ if (BUG(monotime_initialized == 0)) {
+ monotime_init();
+ }
+
monotime_coarse_t now;
monotime_coarse_get(&now);
return monotime_coarse_diff_nsec(&initialized_at_coarse, &now);