[asterisk-commits] mjordan: branch 10 r366948 - in /branches/10: ./ channels/ funcs/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri May 18 10:45:51 CDT 2012


Author: mjordan
Date: Fri May 18 10:45:42 2012
New Revision: 366948

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=366948
Log:
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

(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

Modified:
    branches/10/   (props changed)
    branches/10/channels/chan_sip.c
    branches/10/funcs/func_odbc.c
    branches/10/main/cli.c

Propchange: branches/10/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.

Modified: branches/10/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/branches/10/channels/chan_sip.c?view=diff&rev=366948&r1=366947&r2=366948
==============================================================================
--- branches/10/channels/chan_sip.c (original)
+++ branches/10/channels/chan_sip.c Fri May 18 10:45:42 2012
@@ -7498,6 +7498,7 @@
 	if (f && (f->frametype == AST_FRAME_DTMF_BEGIN || f->frametype == AST_FRAME_DTMF_END) &&
 	    (ast_test_flag(&p->flags[0], SIP_DTMF) != SIP_DTMF_RFC2833)) {
 		ast_debug(1, "Ignoring DTMF (%c) RTP frame because dtmfmode is not RFC2833\n", f->subclass.integer);
+		ast_frfree(f);
 		return &ast_null_frame;
 	}
 
@@ -7510,6 +7511,7 @@
 		if (!ast_format_cap_iscompatible(p->jointcaps, &f->subclass.format)) {
 			ast_debug(1, "Bogus frame of format '%s' received from '%s'!\n",
 				ast_getformatname(&f->subclass.format), p->owner->name);
+			ast_frfree(f);
 			return &ast_null_frame;
 		}
 		ast_debug(1, "Oooh, format changed to %s\n",

Modified: branches/10/funcs/func_odbc.c
URL: http://svnview.digium.com/svn/asterisk/branches/10/funcs/func_odbc.c?view=diff&rev=366948&r1=366947&r2=366948
==============================================================================
--- branches/10/funcs/func_odbc.c (original)
+++ branches/10/funcs/func_odbc.c Fri May 18 10:45:42 2012
@@ -151,6 +151,11 @@
 {
 	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 @@
 			pbx_builtin_setvar_helper(chan, "ODBCROWS", rowcount);
 			ast_autoservice_stop(chan);
 		}
-		ast_free(resultset);
+		odbc_datastore_free(resultset);
 		return -1;
 	}
 
@@ -554,7 +559,7 @@
 			pbx_builtin_setvar_helper(chan, "ODBCROWS", rowcount);
 			ast_autoservice_stop(chan);
 		}
-		ast_free(resultset);
+		odbc_datastore_free(resultset);
 		return -1;
 	}
 
@@ -580,7 +585,7 @@
 			pbx_builtin_setvar_helper(chan, "ODBCSTATUS", status);
 			ast_autoservice_stop(chan);
 		}
-		ast_free(resultset);
+		odbc_datastore_free(resultset);
 		return res1;
 	}
 
@@ -594,7 +599,7 @@
 			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 @@
 					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);

Modified: branches/10/main/cli.c
URL: http://svnview.digium.com/svn/asterisk/branches/10/main/cli.c?view=diff&rev=366948&r1=366947&r2=366948
==============================================================================
--- branches/10/main/cli.c (original)
+++ branches/10/main/cli.c Fri May 18 10:45:42 2012
@@ -2350,8 +2350,10 @@
 
 	/* ensure that the array is NULL terminated */
 	if (matches + 1 >= match_list_len) {
-		if (!(match_list = ast_realloc(match_list, (match_list_len + 1) * sizeof(*match_list))))
+		if (!(match_list = ast_realloc(match_list, (match_list_len + 1) * sizeof(*match_list)))) {
+			ast_free(retstr);
 			return NULL;
+		}
 	}
 	match_list[matches + 1] = NULL;
 




More information about the asterisk-commits mailing list