diff options
author | Matthew Jordan <mjordan@digium.com> | 2012-05-18 15:51:16 +0000 |
---|---|---|
committer | Matthew Jordan <mjordan@digium.com> | 2012-05-18 15:51:16 +0000 |
commit | 6eb4e81033e61d161558fd7cdb015d54e5ac5501 (patch) | |
tree | 297cb73b0df3930d54f022b546b85f56b2cc8dda /funcs/func_odbc.c | |
parent | 7b51320642349100921af1308cb277c21d4fe18c (diff) |
Fix more memory leaks
This patch adds to what was fixed in r366880. Specifically, it addresses the
following:
* chan_sip: dispose of an allocated frame in off nominal code paths in
sip_rtp_read
* func_odbc: when disposing of an allocated resultset, ensure that any rows
that were appended to that resultset are also disposed of
* cli: free the created return string buffer in another off nominal code
path
* chan_dahdi: free a frame that was allocated by the dsp layer if we choose
not to process that frame
(issue ASTERISK-19665)
Reported by: Matt Jordan
Review: https://reviewboard.asterisk.org/r/1922/
........
Merged revisions 366944 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
Merged revisions 366948 from http://svn.asterisk.org/svn/asterisk/branches/10
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@366955 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'funcs/func_odbc.c')
-rw-r--r-- | funcs/func_odbc.c | 15 |
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); |