summaryrefslogtreecommitdiff
path: root/funcs
diff options
context:
space:
mode:
Diffstat (limited to 'funcs')
-rw-r--r--funcs/func_odbc.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/funcs/func_odbc.c b/funcs/func_odbc.c
index 72a87cc0b..5b24878a6 100644
--- a/funcs/func_odbc.c
+++ b/funcs/func_odbc.c
@@ -151,6 +151,11 @@ static void odbc_datastore_free(void *data)
{
struct odbc_datastore *result = data;
struct odbc_datastore_row *row;
+
+ if (!result) {
+ return;
+ }
+
AST_LIST_LOCK(result);
while ((row = AST_LIST_REMOVE_HEAD(result, list))) {
ast_free(row);
@@ -539,7 +544,7 @@ static int acf_odbc_read(struct ast_channel *chan, const char *cmd, char *s, cha
pbx_builtin_setvar_helper(chan, "ODBCROWS", rowcount);
ast_autoservice_stop(chan);
}
- ast_free(resultset);
+ odbc_datastore_free(resultset);
return -1;
}
@@ -554,7 +559,7 @@ static int acf_odbc_read(struct ast_channel *chan, const char *cmd, char *s, cha
pbx_builtin_setvar_helper(chan, "ODBCROWS", rowcount);
ast_autoservice_stop(chan);
}
- ast_free(resultset);
+ odbc_datastore_free(resultset);
return -1;
}
@@ -580,7 +585,7 @@ static int acf_odbc_read(struct ast_channel *chan, const char *cmd, char *s, cha
pbx_builtin_setvar_helper(chan, "ODBCSTATUS", status);
ast_autoservice_stop(chan);
}
- ast_free(resultset);
+ odbc_datastore_free(resultset);
return res1;
}
@@ -594,7 +599,7 @@ static int acf_odbc_read(struct ast_channel *chan, const char *cmd, char *s, cha
char *ptrcoldata;
if (!coldata) {
- ast_free(resultset);
+ odbc_datastore_free(resultset);
SQLCloseCursor(stmt);
SQLFreeHandle(SQL_HANDLE_STMT, stmt);
ast_odbc_release_obj(obj);
@@ -627,7 +632,7 @@ static int acf_odbc_read(struct ast_channel *chan, const char *cmd, char *s, cha
void *tmp = ast_realloc(resultset, sizeof(*resultset) + ast_str_strlen(colnames) + 1);
if (!tmp) {
ast_log(LOG_ERROR, "No space for a new resultset?\n");
- ast_free(resultset);
+ odbc_datastore_free(resultset);
SQLCloseCursor(stmt);
SQLFreeHandle(SQL_HANDLE_STMT, stmt);
ast_odbc_release_obj(obj);