]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
lock.c: Check *lt before dereferencing it 75/2675/1
authorDiederik de Groot <dkgroot@talon.nl>
Thu, 21 Apr 2016 13:26:47 +0000 (15:26 +0200)
committerJoshua Colp <jcolp@digium.com>
Thu, 21 Apr 2016 16:35:51 +0000 (11:35 -0500)
*lt is NULL if t->tracking == 0

ASTERISK-25948 #close

Change-Id: I4a81af28f9c82a74aa82413d772a7dc8fa6f45ba

main/lock.c

index dd90d7bd9a9f920516f9f7504a6a8c7dc73255d1..03f1cd974a30b54d235d58e524085e02cc4d5c02 100644 (file)
@@ -286,17 +286,19 @@ int __ast_pthread_mutex_lock(const char *filename, int lineno, const char *func,
                                if (wait_time > reported_wait && (wait_time % 5) == 0) {
                                        __ast_mutex_logger("%s line %d (%s): Deadlock? waited %d sec for mutex '%s'?\n",
                                                           filename, lineno, func, (int) wait_time, mutex_name);
-                                       ast_reentrancy_lock(lt);
+                                       if (lt) {
+                                               ast_reentrancy_lock(lt);
 #ifdef HAVE_BKTR
-                                       __dump_backtrace(&lt->backtrace[lt->reentrancy], canlog);
+                                               __dump_backtrace(&lt->backtrace[lt->reentrancy], canlog);
 #endif
-                                       __ast_mutex_logger("%s line %d (%s): '%s' was locked here.\n",
-                                                          lt->file[ROFFSET], lt->lineno[ROFFSET],
-                                                          lt->func[ROFFSET], mutex_name);
+                                               __ast_mutex_logger("%s line %d (%s): '%s' was locked here.\n",
+                                                                  lt->file[ROFFSET], lt->lineno[ROFFSET],
+                                                                  lt->func[ROFFSET], mutex_name);
 #ifdef HAVE_BKTR
-                                       __dump_backtrace(&lt->backtrace[ROFFSET], canlog);
+                                               __dump_backtrace(&lt->backtrace[ROFFSET], canlog);
 #endif
-                                       ast_reentrancy_unlock(lt);
+                                               ast_reentrancy_unlock(lt);
+                                       }
                                        reported_wait = wait_time;
                                }
                                usleep(200);