summaryrefslogtreecommitdiff
path: root/src/common/log.c
diff options
context:
space:
mode:
authorteor (Tim Wilson-Brown) <teor2345@gmail.com>2016-02-05 14:08:58 +1100
committerteor (Tim Wilson-Brown) <teor2345@gmail.com>2016-02-05 14:08:58 +1100
commitdb72b509d17311d289b140afb3456376c5525ad7 (patch)
treecc3873bf0937e90dcf14096498f9d5d06c278add /src/common/log.c
parentc595f6d25e9cda58f5327c5806e2c9a534c454f9 (diff)
downloadtor-db72b509d17311d289b140afb3456376c5525ad7.tar.gz
tor-db72b509d17311d289b140afb3456376c5525ad7.zip
Check that the log mutex is initialised before trying to lock or unlock it
Diffstat (limited to 'src/common/log.c')
-rw-r--r--src/common/log.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/common/log.c b/src/common/log.c
index 4a8a7b1165..f71583fd63 100644
--- a/src/common/log.c
+++ b/src/common/log.c
@@ -149,10 +149,14 @@ static int pretty_fn_has_parens = 0;
/** Lock the log_mutex to prevent others from changing the logfile_t list */
#define LOCK_LOGS() STMT_BEGIN \
+ tor_assert(log_mutex_initialized); \
tor_mutex_acquire(&log_mutex); \
STMT_END
/** Unlock the log_mutex */
-#define UNLOCK_LOGS() STMT_BEGIN tor_mutex_release(&log_mutex); STMT_END
+#define UNLOCK_LOGS() STMT_BEGIN \
+ tor_assert(log_mutex_initialized); \
+ tor_mutex_release(&log_mutex); \
+ STMT_END
/** What's the lowest log level anybody cares about? Checking this lets us
* bail out early from log_debug if we aren't debugging. */
@@ -482,6 +486,8 @@ logv,(int severity, log_domain_mask_t domain, const char *funcname,
/* check that severity is sane. Overrunning the masks array leads to
* interesting and hard to diagnose effects */
assert(severity >= LOG_ERR && severity <= LOG_DEBUG);
+ /* check that we've initialised the log mutex before we try to lock it */
+ assert(log_mutex_initialized);
LOCK_LOGS();
if ((! (domain & LD_NOCB)) && smartlist_len(pending_cb_messages))