[asterisk-commits] tilghman: trunk r135476 - in /trunk: include/asterisk/ main/ res/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Aug 4 11:34:04 CDT 2008


Author: tilghman
Date: Mon Aug  4 11:34:04 2008
New Revision: 135476

URL: http://svn.digium.com/view/asterisk?view=rev&rev=135476
Log:
HTTP module memory leaks
(closes issue #13230)
 Reported by: eliel
 Patches: 
       res_http_post_leak.patch uploaded by eliel (license 64)

Modified:
    trunk/include/asterisk/http.h
    trunk/main/http.c
    trunk/res/res_http_post.c

Modified: trunk/include/asterisk/http.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/http.h?view=diff&rev=135476&r1=135475&r2=135476
==============================================================================
--- trunk/include/asterisk/http.h (original)
+++ trunk/include/asterisk/http.h Mon Aug  4 11:34:04 2008
@@ -87,9 +87,13 @@
 	unsigned int supports_get:1;
 	/*! This handler accepts POST requests */
 	unsigned int supports_post:1;
+	/*! Structure is malloc'd */
+	unsigned int mallocd:1;
+	/*! Data structure is malloc'd */
+	unsigned int dmallocd:1;
 	/*! Data to bind to the uri if needed */
 	void *data;
-	/*! Key to be used for unlinking if multipile URIs registerd */
+	/*! Key to be used for unlinking if multiple URIs registered */
 	const char *key;
 };
 

Modified: trunk/main/http.c
URL: http://svn.digium.com/view/asterisk/trunk/main/http.c?view=diff&rev=135476&r1=135475&r2=135476
==============================================================================
--- trunk/main/http.c (original)
+++ trunk/main/http.c Mon Aug  4 11:34:04 2008
@@ -388,6 +388,12 @@
 	AST_RWLIST_TRAVERSE_SAFE_BEGIN(&uris, urih, entry) {
 		if (!strcmp(urih->key, key)) {
 			AST_RWLIST_REMOVE_CURRENT(entry);
+		}
+		if (urih->dmallocd) {
+			ast_free(urih->data);
+		}
+		if (urih->mallocd) {
+			ast_free(urih);
 		}
 	}
 	AST_RWLIST_TRAVERSE_SAFE_END

Modified: trunk/res/res_http_post.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_http_post.c?view=diff&rev=135476&r1=135475&r2=135476
==============================================================================
--- trunk/res/res_http_post.c (original)
+++ trunk/res/res_http_post.c Mon Aug  4 11:34:04 2008
@@ -289,12 +289,15 @@
 			struct ast_str *ds;
 
 			if (!(urih = ast_calloc(sizeof(*urih), 1))) {
+				ast_config_destroy(cfg);
 				return -1;
 			}
 
-			if (!(ds = ast_str_create(32)))
+			if (!(ds = ast_str_create(32))) {
+				ast_free(urih);
+				ast_config_destroy(cfg);
 				return -1;
-
+			}
 
 			urih->description = ast_strdup("HTTP POST mapping");
 			urih->uri = ast_strdup(v->name);
@@ -305,6 +308,7 @@
 			urih->supports_post = 1;
 			urih->callback = http_post_callback;
 			urih->key = __FILE__;
+			urih->mallocd = urih->dmallocd = 1;
 
 			ast_http_uri_link(urih);
 		}
@@ -323,7 +327,6 @@
 
 static int reload(void)
 {
-
 	__ast_http_post_load(1);
 
 	return AST_MODULE_LOAD_SUCCESS;




More information about the asterisk-commits mailing list