From d0dcc747233047878273f8404b6279c87d7bf0e2 Mon Sep 17 00:00:00 2001 From: Tilghman Lesher Date: Thu, 3 Jun 2010 19:51:06 +0000 Subject: [PATCH] Merged revisions 267669 via svnmerge from https://origsvn.digium.com/svn/asterisk/trunk ........ r267669 | tilghman | 2010-06-03 14:46:42 -0500 (Thu, 03 Jun 2010) | 8 lines Handle OOM errors more gracefully. (closes issue #17084) Reported by: falves11 Patches: issue17084_162_A.diff uploaded by falves11 (license 374) Tested by: falves11 ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.2@267670 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- funcs/func_odbc.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/funcs/func_odbc.c b/funcs/func_odbc.c index 5bb66c38b8..123d55abf1 100644 --- a/funcs/func_odbc.c +++ b/funcs/func_odbc.c @@ -219,7 +219,7 @@ static int acf_odbc_write(struct ast_channel *chan, const char *cmd, char *s, co struct ast_str *insertbuf = ast_str_thread_get(&sql2_buf, 16); const char *status = "FAILURE"; - if (!buf) { + if (!buf || !insertbuf) { return -1; } @@ -396,7 +396,7 @@ static int acf_odbc_read(struct ast_channel *chan, const char *cmd, char *s, cha struct ast_str *sql = ast_str_thread_get(&sql_buf, 16); const char *status = "FAILURE"; - if (!sql) { + if (!sql || !colnames) { pbx_builtin_setvar_helper(chan, "ODBCSTATUS", status); return -1; } @@ -539,6 +539,21 @@ static int acf_odbc_read(struct ast_channel *chan, const char *cmd, char *s, cha struct ast_str *coldata = ast_str_thread_get(&coldata_buf, 16); char *ptrcoldata; + if (!coldata) { + ast_free(resultset); + SQLCloseCursor(stmt); + SQLFreeHandle(SQL_HANDLE_STMT, stmt); + ast_odbc_release_obj(obj); + obj = NULL; + pbx_builtin_setvar_helper(chan, "ODBCSTATUS", "MEMERROR"); + if (chan) + ast_autoservice_stop(chan); + if (bogus_chan) { + ast_channel_free(chan); + } + return -1; + } + if (y == 0) { char colname[256]; SQLULEN maxcol; @@ -1083,6 +1098,11 @@ static char *cli_odbc_read(struct ast_cli_entry *e, int cmd, struct ast_cli_args char colname[256]; SQLULEN maxcol; + if (!coldata) { + AST_RWLIST_UNLOCK(&queries); + return CLI_SUCCESS; + } + for (dsn = 0; dsn < 5; dsn++) { if (ast_strlen_zero(query->readhandle[dsn])) { continue; -- 2.47.2