[Asterisk-code-review] pbx: Fix leak of timezone for time based includes. (asterisk[master])

Anonymous Coward asteriskteam at digium.com
Thu Jul 14 12:14:44 CDT 2016


Anonymous Coward #1000019 has submitted this change and it was merged.

Change subject: pbx: Fix leak of timezone for time based includes.
......................................................................


pbx: Fix leak of timezone for time based includes.

Create include_free to run ast_destroy_timing and ast_free, use that in
all places that freed an ast_include structure.  This fixes a couple of
paths that previously did not run ast_destroy_timing.

ASTERISK-26196 #close

Change-Id: I1671bd111bef0dc113e8bf8f77f89fcfc395d838
---
M main/pbx.c
1 file changed, 12 insertions(+), 7 deletions(-)

Approvals:
  George Joseph: Looks good to me, but someone else must approve
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, approved



diff --git a/main/pbx.c b/main/pbx.c
index df9cad3..f065b1a 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -4755,6 +4755,13 @@
 	return c;
 }
 
+/*! \brief Free an ast_include and associated data. */
+static void include_free(struct ast_include *include)
+{
+	ast_destroy_timing(&(include->timing));
+	ast_free(include);
+}
+
 /*!
  * \brief Remove included contexts.
  * This function locks contexts list by &conlist, search for the right context
@@ -4802,8 +4809,7 @@
 			else
 				con->includes = i->next;
 			/* free include and return */
-			ast_destroy_timing(&(i->timing));
-			ast_free(i);
+			include_free(i);
 			ret = 0;
 			break;
 		}
@@ -6613,8 +6619,7 @@
 	/* ... go to last include and check if context is already included too... */
 	for (i = con->includes; i; i = i->next) {
 		if (!strcasecmp(i->name, new_include->name)) {
-			ast_destroy_timing(&(new_include->timing));
-			ast_free(new_include);
+			include_free(new_include);
 			ast_unlock_context(con);
 			errno = EEXIST;
 			return -1;
@@ -7838,7 +7843,7 @@
 	for (tmpi = tmp->includes; tmpi; ) { /* Free includes */
 		struct ast_include *tmpil = tmpi;
 		tmpi = tmpi->next;
-		ast_free(tmpil);
+		include_free(tmpil);
 	}
 	for (ipi = tmp->ignorepats; ipi; ) { /* Free ignorepats */
 		struct ast_ignorepat *ipl = ipi;
@@ -7932,12 +7937,12 @@
 					if (pi) {
 						pi->next = i->next;
 						/* free include */
-						ast_free(i);
+						include_free(i);
 						continue; /* don't change pi */
 					} else {
 						tmp->includes = i->next;
 						/* free include */
-						ast_free(i);
+						include_free(i);
 						continue; /* don't change pi */
 					}
 				}

-- 
To view, visit https://gerrit.asterisk.org/3203
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I1671bd111bef0dc113e8bf8f77f89fcfc395d838
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>



More information about the asterisk-code-review mailing list