[Asterisk-code-review] func_odbc: expose ARGC in addition to ARGn. (asterisk[master])

Jaco Kroon asteriskteam at digium.com
Wed Feb 17 14:59:24 CST 2021


Jaco Kroon has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/15448 )


Change subject: func_odbc:  expose ARGC in addition to ARGn.
......................................................................

func_odbc:  expose ARGC in addition to ARGn.

This is needed if you're using optional argument, to verify whether or
not an argument has been passed, else it's possible to use a leaked ARGn
from Gosub (app_stack).

Change-Id: I6ca0b137d90b03f6aa9c496991f6cbf1518f6c24
Signed-off-by: Jaco Kroon <jaco at uls.co.za>
---
M funcs/func_odbc.c
1 file changed, 4 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/48/15448/1

diff --git a/funcs/func_odbc.c b/funcs/func_odbc.c
index 5cc0faa..2f09441 100644
--- a/funcs/func_odbc.c
+++ b/funcs/func_odbc.c
@@ -579,6 +579,8 @@
 	}
 
 	AST_STANDARD_APP_ARGS(args, s);
+	snprintf(varname, sizeof(varname), "%u", args.argc);
+	pbx_builtin_pushvar_helper(chan, "ARGC", varname);
 	for (i = 0; i < args.argc; i++) {
 		snprintf(varname, sizeof(varname), "ARG%d", i + 1);
 		pbx_builtin_pushvar_helper(chan, varname, args.field[i]);
@@ -603,6 +605,8 @@
 		chan = ast_channel_unref(chan);
 	} else {
 		/* Restore prior values */
+		pbx_builtin_setvar_helper(chan, "ARGC", NULL);
+
 		for (i = 0; i < args.argc; i++) {
 			snprintf(varname, sizeof(varname), "ARG%d", i + 1);
 			pbx_builtin_setvar_helper(chan, varname, NULL);

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/15448
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I6ca0b137d90b03f6aa9c496991f6cbf1518f6c24
Gerrit-Change-Number: 15448
Gerrit-PatchSet: 1
Gerrit-Owner: Jaco Kroon <jaco at uls.co.za>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210217/cfddff9a/attachment.html>


More information about the asterisk-code-review mailing list