[tor-commits] [tor/master] Make sure initialized_at is initialized before use.
nickm at torproject.org
nickm at torproject.org
Tue Jul 19 09:42:34 UTC 2016
commit 6ba415d4000712aecaf3d11903db5699f143569d
Author: Nick Mathewson <nickm at torproject.org>
Date: Tue Jul 19 11:36:43 2016 +0200
Make sure initialized_at is initialized before use.
---
src/common/compat_time.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/common/compat_time.c b/src/common/compat_time.c
index de39566..b7d69cf 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);
More information about the tor-commits
mailing list