mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 11:25:35 +00:00
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/trunk@267669 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -221,7 +221,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);
|
struct ast_str *insertbuf = ast_str_thread_get(&sql2_buf, 16);
|
||||||
const char *status = "FAILURE";
|
const char *status = "FAILURE";
|
||||||
|
|
||||||
if (!buf) {
|
if (!buf || !insertbuf) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -406,7 +406,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);
|
struct ast_str *sql = ast_str_thread_get(&sql_buf, 16);
|
||||||
const char *status = "FAILURE";
|
const char *status = "FAILURE";
|
||||||
|
|
||||||
if (!sql) {
|
if (!sql || !colnames) {
|
||||||
if (chan) {
|
if (chan) {
|
||||||
pbx_builtin_setvar_helper(chan, "ODBCSTATUS", status);
|
pbx_builtin_setvar_helper(chan, "ODBCSTATUS", status);
|
||||||
}
|
}
|
||||||
@@ -567,6 +567,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);
|
struct ast_str *coldata = ast_str_thread_get(&coldata_buf, 16);
|
||||||
char *ptrcoldata;
|
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_release(chan);
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (y == 0) {
|
if (y == 0) {
|
||||||
char colname[256];
|
char colname[256];
|
||||||
SQLULEN maxcol;
|
SQLULEN maxcol;
|
||||||
@@ -1126,6 +1141,11 @@ static char *cli_odbc_read(struct ast_cli_entry *e, int cmd, struct ast_cli_args
|
|||||||
char colname[256];
|
char colname[256];
|
||||||
SQLULEN maxcol;
|
SQLULEN maxcol;
|
||||||
|
|
||||||
|
if (!coldata) {
|
||||||
|
AST_RWLIST_UNLOCK(&queries);
|
||||||
|
return CLI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
for (dsn = 0; dsn < 5; dsn++) {
|
for (dsn = 0; dsn < 5; dsn++) {
|
||||||
if (ast_strlen_zero(query->readhandle[dsn])) {
|
if (ast_strlen_zero(query->readhandle[dsn])) {
|
||||||
continue;
|
continue;
|
||||||
|
Reference in New Issue
Block a user