diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-10-15 19:25:56 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-10-15 19:25:56 +0000 |
commit | 8381ecb24000935e815839fa6c03f7137677a5a6 (patch) | |
tree | 3b631bbe098580ad584ff44ae43947360e14752e /main | |
parent | bc130eab84917205e3f977e6528fcf797dcb143a (diff) |
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.
........
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@85650 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r-- | main/utils.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/main/utils.c b/main/utils.c index 320516e33..25de47ef3 100644 --- a/main/utils.c +++ b/main/utils.c @@ -742,13 +742,16 @@ static char *handle_show_locks(struct ast_cli_entry *e, int cmd, struct ast_cli_ "=== <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 @@ static char *handle_show_locks(struct ast_cli_entry *e, int cmd, struct ast_cli_ 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[] = { |