From: Russell Bryant Date: Thu, 7 Oct 2010 10:53:56 +0000 (+0000) Subject: Don't crash when Set() is called without a value. X-Git-Tag: 1.6.2.15-rc1~53 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a0536b1e6604346477f4a7e4d5a879e9f8d4ed02;p=thirdparty%2Fasterisk.git Don't crash when Set() is called without a value. Review: https://reviewboard.asterisk.org/r/949/ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.2@290712 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/main/pbx.c b/main/pbx.c index 62c9d8d2fc..9fb0c8bb01 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -9111,11 +9111,18 @@ int pbx_builtin_setvar(struct ast_channel *chan, void *data) mydata = ast_strdupa(data); name = strsep(&mydata, "="); value = mydata; - if (strchr(name, ' ')) + if (!value) { + ast_log(LOG_WARNING, "Set requires an '=' to be a valid assignment.\n"); + return 0; + } + + if (strchr(name, ' ')) { ast_log(LOG_WARNING, "Please avoid unnecessary spaces on variables as it may lead to unexpected results ('%s' set to '%s').\n", name, mydata); + } pbx_builtin_setvar_helper(chan, name, value); - return(0); + + return 0; } int pbx_builtin_setvar_multiple(struct ast_channel *chan, void *vdata)