[Asterisk-code-review] PBX: Handle errors from AST VECTOR APPEND. (asterisk[master])

Jenkins2 asteriskteam at digium.com
Tue Nov 7 15:27:27 CST 2017


Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/7037 )

Change subject: PBX: Handle errors from AST_VECTOR_APPEND.
......................................................................

PBX: Handle errors from AST_VECTOR_APPEND.

This resolves potentials leaks on AST_VECTOR_APPEND error in:
* ast_context_add_include2
* ast_context_add_switch2
* ast_context_add_ignorepat2

Change-Id: Ib60e95c4f622fa3b832d87227c0523a695d736b6
---
M main/pbx.c
1 file changed, 15 insertions(+), 3 deletions(-)

Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, but someone else must approve
  Richard Mudgett: Looks good to me, approved
  Jenkins2: Approved for Submit



diff --git a/main/pbx.c b/main/pbx.c
index 2366b72..b5602b5 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -6692,7 +6692,11 @@
 	}
 
 	/* ... include new context into context list, unlock, return */
-	AST_VECTOR_APPEND(&con->includes, new_include);
+	if (AST_VECTOR_APPEND(&con->includes, new_include)) {
+		include_free(new_include);
+		ast_unlock_context(con);
+		return -1;
+	}
 	ast_verb(3, "Including context '%s' in context '%s'\n",
 		ast_get_include_name(new_include), ast_get_context_name(con));
 
@@ -6754,7 +6758,11 @@
 	}
 
 	/* ... sw new context into context list, unlock, return */
-	AST_VECTOR_APPEND(&con->alts, new_sw);
+	if (AST_VECTOR_APPEND(&con->alts, new_sw)) {
+		sw_free(new_sw);
+		ast_unlock_context(con);
+		return -1;
+	}
 
 	ast_verb(3, "Including switch '%s/%s' in context '%s'\n",
 		ast_get_switch_name(new_sw), ast_get_switch_data(new_sw), ast_get_context_name(con));
@@ -6842,7 +6850,11 @@
 			return -1;
 		}
 	}
-	AST_VECTOR_APPEND(&con->ignorepats, ignorepat);
+	if (AST_VECTOR_APPEND(&con->ignorepats, ignorepat)) {
+		ignorepat_free(ignorepat);
+		ast_unlock_context(con);
+		return -1;
+	}
 	ast_unlock_context(con);
 
 	return 0;

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

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib60e95c4f622fa3b832d87227c0523a695d736b6
Gerrit-Change-Number: 7037
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171107/9b5b7687/attachment.html>


More information about the asterisk-code-review mailing list