diff options
author | citats <citats@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-10-23 07:03:01 +0000 |
---|---|---|
committer | citats <citats@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-10-23 07:03:01 +0000 |
commit | 5b9e1b51b200a4b887628516691cae72cc7fd2dc (patch) | |
tree | 3190ad4709980190e2ddb8abea52b8162400b66d /res | |
parent | 541c114058dbf1ce92562c69dfd88044b451c980 (diff) |
More memory checks
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@4056 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res')
-rwxr-xr-x | res/res_monitor.c | 10 | ||||
-rwxr-xr-x | res/res_odbc.c | 12 |
2 files changed, 18 insertions, 4 deletions
diff --git a/res/res_monitor.c b/res/res_monitor.c index c36460c5a..966295897 100755 --- a/res/res_monitor.c +++ b/res/res_monitor.c @@ -90,6 +90,11 @@ int ast_monitor_start( struct ast_channel *chan, const char *format_spec, } monitor = malloc(sizeof(struct ast_channel_monitor)); + if (!monitor) { + if (need_lock) + ast_mutex_unlock(&chan->lock); + return -1; + } memset(monitor, 0, sizeof(struct ast_channel_monitor)); /* Determine file names */ @@ -391,6 +396,11 @@ static int start_monitor_action(struct mansession *s, struct message *m) if ((!fname) || (ast_strlen_zero(fname))) { // No filename base specified, default to channel name as per CLI fname = malloc (FILENAME_MAX); + if (!fname) { + astman_send_error(s, m, "Could not start monitoring channel"); + ast_mutex_unlock(&c->lock); + return 0; + } memset(fname, 0, FILENAME_MAX); strncpy(fname, c->name, FILENAME_MAX-1); // Channels have the format technology/channel_name - have to replace that / diff --git a/res/res_odbc.c b/res/res_odbc.c index c6f432ada..dde43353f 100755 --- a/res/res_odbc.c +++ b/res/res_odbc.c @@ -99,10 +99,12 @@ static int load_odbc_config(void) if (!strcmp(cat, "ENV")) { for (v = ast_variable_browse(config, cat); v; v = v->next) { env_var = malloc(strlen(v->name) + strlen(v->value) + 2); - sprintf(env_var, "%s=%s", v->name, v->value); - ast_log(LOG_NOTICE, "Adding ENV var: %s=%s\n", v->name, v->value); - putenv(env_var); - free(env_var); + if (env_var) { + sprintf(env_var, "%s=%s", v->name, v->value); + ast_log(LOG_NOTICE, "Adding ENV var: %s=%s\n", v->name, v->value); + putenv(env_var); + free(env_var); + } } cat = ast_category_browse(config, cat); @@ -222,6 +224,8 @@ odbc_obj *new_odbc_obj(char *name, char *dsn, char *username, char *password) static odbc_obj *new; new = malloc(sizeof(odbc_obj)); + if (!new) + return NULL; memset(new, 0, sizeof(odbc_obj)); new->env = SQL_NULL_HANDLE; |