Index: funcs/func_odbc.c =================================================================== --- funcs/func_odbc.c (revision 161946) +++ funcs/func_odbc.c (working copy) @@ -963,7 +963,7 @@ 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 @@ 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 @@ 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 @@ 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])) {