[Asterisk-code-review] pbx: Prevent execution of NULL pointer. (asterisk[master])

Corey Farrell asteriskteam at digium.com
Thu Jan 4 15:44:14 CST 2018


Corey Farrell has uploaded this change for review. ( https://gerrit.asterisk.org/7805


Change subject: pbx: Prevent execution of NULL pointer.
......................................................................

pbx: Prevent execution of NULL pointer.

pbx_extension_helper has a check for q->swo.exec == NULL but it doesn't
actually return so we would still run the function.  Fix the return.
Also move the 'int res' variable into the only scope which uses it.

Change-Id: I0693af921fdc7f56b6a72a21fb816ed08b960a69
---
M main/pbx.c
1 file changed, 6 insertions(+), 4 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/05/7805/1

diff --git a/main/pbx.c b/main/pbx.c
index 12daa67..ecdd9a0 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -2863,7 +2863,6 @@
 	struct ast_exten *e;
 	struct ast_app *app;
 	char *substitute = NULL;
-	int res;
 	struct pbx_find_info q = { .stacklen = 0 }; /* the rest is reset in pbx_find_extension */
 	char passdata[EXT_DATA_SIZE];
 	int matching_action = (action == E_MATCH || action == E_CANMATCH || action == E_MATCHMORE);
@@ -2880,9 +2879,12 @@
 			ast_unlock_contexts();
 			return -1;	/* success, we found it */
 		} else if (action == E_FINDLABEL) { /* map the label to a priority */
-			res = e->priority;
+			int res = e->priority;
+
 			ast_unlock_contexts();
-			return res;	/* the priority we were looking for */
+
+			/* the priority we were looking for */
+			return res;
 		} else {	/* spawn */
 			if (!e->cached_app)
 				e->cached_app = pbx_findapp(e->app);
@@ -2932,7 +2934,7 @@
 		} else {
 			if (!q.swo->exec) {
 				ast_log(LOG_WARNING, "No execution engine for switch %s\n", q.swo->name);
-				res = -1;
+				return -1;
 			}
 			return q.swo->exec(c, q.foundcontext ? q.foundcontext : context, exten, priority, callerid, q.data);
 		}

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

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0693af921fdc7f56b6a72a21fb816ed08b960a69
Gerrit-Change-Number: 7805
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180104/8b846085/attachment.html>


More information about the asterisk-code-review mailing list