[asterisk-commits] pbx: Fix leak of timezone for time based includes. (asterisk[13])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jul 14 12:05:21 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 6b0069c..5bafee3 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -4682,6 +4682,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
@@ -4729,8 +4736,7 @@
 			else
 				con->includes = i->next;
 			/* free include and return */
-			ast_destroy_timing(&(i->timing));
-			ast_free(i);
+			include_free(i);
 			ret = 0;
 			break;
 		}
@@ -6481,8 +6487,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;
@@ -7706,7 +7711,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;
@@ -7800,12 +7805,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/3202
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I1671bd111bef0dc113e8bf8f77f89fcfc395d838
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
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-commits mailing list