[asterisk-commits] russell: trunk r85650 - in /trunk: ./ main/utils.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Oct 15 14:25:56 CDT 2007
Author: russell
Date: Mon Oct 15 14:25:56 2007
New Revision: 85650
URL: http://svn.digium.com/view/asterisk?view=rev&rev=85650
Log:
Merged revisions 85649 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r85649 | russell | 2007-10-15 14:22:45 -0500 (Mon, 15 Oct 2007) | 2 lines
Be pedantic about handling memory allocation failure.
........
Modified:
trunk/ (props changed)
trunk/main/utils.c
Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.
Modified: trunk/main/utils.c
URL: http://svn.digium.com/view/asterisk/trunk/main/utils.c?view=diff&rev=85650&r1=85649&r2=85650
==============================================================================
--- trunk/main/utils.c (original)
+++ trunk/main/utils.c Mon Oct 15 14:25:56 2007
@@ -742,13 +742,16 @@
"=== <file> <line num> <function> <lock name> <lock addr> (times locked)\n"
"===\n");
+ if (!str)
+ return CLI_FAILURE;
+
pthread_mutex_lock(&lock_infos_lock.mutex);
AST_LIST_TRAVERSE(&lock_infos, lock_info, entry) {
int i;
ast_str_append(&str, 0, "=== Thread ID: %d (%s)\n", (int) lock_info->thread_id,
lock_info->thread_name);
pthread_mutex_lock(&lock_info->lock);
- for (i = 0; i < lock_info->num_locks; i++) {
+ for (i = 0; str && i < lock_info->num_locks; i++) {
ast_str_append(&str, 0, "=== ---> %sLock #%d (%s): %s %d %s %s %p (%d)\n",
lock_info->locks[i].pending > 0 ? "Waiting for " :
lock_info->locks[i].pending < 0 ? "Tried and failed to get " : "", i,
@@ -760,19 +763,29 @@
lock_info->locks[i].times_locked);
}
pthread_mutex_unlock(&lock_info->lock);
+ if (!str)
+ break;
ast_str_append(&str, 0, "=== -------------------------------------------------------------------\n"
"===\n");
+ if (!str)
+ break;
}
pthread_mutex_unlock(&lock_infos_lock.mutex);
+
+ if (!str)
+ return CLI_FAILURE;
ast_str_append(&str, 0, "=======================================================================\n"
"\n");
+ if (!str)
+ return CLI_FAILURE;
+
ast_cli(a->fd, "%s", str->str);
free(str);
- return 0;
+ return CLI_SUCCESS;
}
static struct ast_cli_entry utils_cli[] = {
More information about the asterisk-commits
mailing list