diff --git a/main/lock.c b/main/lock.c
index 3c9fbd4dbd5454304508f96e032475e422a7d54f..902d631193c2a3910dfc18530ad6afc5e20b27ce 100644
--- a/main/lock.c
+++ b/main/lock.c
@@ -745,7 +745,7 @@ int __ast_rwlock_destroy(const char *filename, int lineno, const char *func, con
 		__ast_mutex_logger("%s line %d (%s): Error destroying rwlock %s: %s\n",
 				filename, lineno, func, rwlock_name, strerror(res));
 	}
-	if (t->tracking) {
+	if (t->tracking && lt) {
 		ast_reentrancy_lock(lt);
 		lt->file[0] = filename;
 		lt->lineno[0] = lineno;