aboutsummaryrefslogtreecommitdiffstats
path: root/funcs/func_odbc.c
diff options
context:
space:
mode:
authoreliel <eliel@f38db490-d61c-443f-a65b-d21fe96a405b>2008-12-09 14:49:30 +0000
committereliel <eliel@f38db490-d61c-443f-a65b-d21fe96a405b>2008-12-09 14:49:30 +0000
commitcf6cd2d414de9e85060ea08d9ad643e00d30b5c3 (patch)
treee5379a58c772cc50717c4d6e87c60bab1eb8d50c /funcs/func_odbc.c
parent271fa07aace07e9fce1f3625c382337874592809 (diff)
Avoid allocating memory for a thread that don't need it. Also, this memory was not being freed until the
main thread ends. (That is never). (closes issue #14040) Reported by: eliel Patches: func_odbc.c.patch uploaded by eliel (license 64) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@161947 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'funcs/func_odbc.c')
-rw-r--r--funcs/func_odbc.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/funcs/func_odbc.c b/funcs/func_odbc.c
index e0f4eb302..36f530c6a 100644
--- a/funcs/func_odbc.c
+++ b/funcs/func_odbc.c
@@ -963,7 +963,7 @@ static char *cli_odbc_read(struct ast_cli_entry *e, int cmd, struct ast_cli_args
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(field)[100];
);
- struct ast_str *sql = ast_str_thread_get(&sql_buf, 16);
+ struct ast_str *sql;
char *char_args, varname[10];
struct acf_odbc_query *query;
struct ast_channel *chan;
@@ -1005,6 +1005,11 @@ static char *cli_odbc_read(struct ast_cli_entry *e, int cmd, struct ast_cli_args
return CLI_SHOWUSAGE;
}
+ sql = ast_str_thread_get(&sql_buf, 16);
+ if (!sql) {
+ return CLI_FAILURE;
+ }
+
AST_RWLIST_RDLOCK(&queries);
AST_RWLIST_TRAVERSE(&queries, query, list) {
if (!strcmp(query->acf->name, a->argv[2])) {
@@ -1156,7 +1161,7 @@ static char *cli_odbc_write(struct ast_cli_entry *e, int cmd, struct ast_cli_arg
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(field)[100];
);
- struct ast_str *sql = ast_str_thread_get(&sql_buf, 16);
+ struct ast_str *sql;
char *char_args, *char_values, varname[10];
struct acf_odbc_query *query;
struct ast_channel *chan;
@@ -1198,6 +1203,11 @@ static char *cli_odbc_write(struct ast_cli_entry *e, int cmd, struct ast_cli_arg
return CLI_SHOWUSAGE;
}
+ sql = ast_str_thread_get(&sql_buf, 16);
+ if (!sql) {
+ return CLI_FAILURE;
+ }
+
AST_RWLIST_RDLOCK(&queries);
AST_RWLIST_TRAVERSE(&queries, query, list) {
if (!strcmp(query->acf->name, a->argv[2])) {