diff options
author | Kinsey Moore <kmoore@digium.com> | 2012-07-31 20:21:43 +0000 |
---|---|---|
committer | Kinsey Moore <kmoore@digium.com> | 2012-07-31 20:21:43 +0000 |
commit | 9b16c8b0f6c3b6310e303411421bfcb16b26c3c4 (patch) | |
tree | 273c31a834a21bd2239ec6b83cd35c602ea25d26 /main/pbx.c | |
parent | 6c23a60f802e7708389b1a6463a40dc0500512bd (diff) |
Clean up and ensure proper usage of alloca()
This replaces all calls to alloca() with ast_alloca() which calls gcc's
__builtin_alloca() to avoid BSD semantics and removes all NULL checks
on memory allocated via ast_alloca() and ast_strdupa().
(closes issue ASTERISK-20125)
Review: https://reviewboard.asterisk.org/r/2032/
Patch-by: Walter Doekes (wdoekes)
........
Merged revisions 370642 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
Merged revisions 370643 from http://svn.asterisk.org/svn/asterisk/branches/10
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@370655 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/pbx.c')
-rw-r--r-- | main/pbx.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/main/pbx.c b/main/pbx.c index a1ed1b52d..ef04d6644 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -4191,7 +4191,7 @@ void pbx_substitute_variables_helper_full(struct ast_channel *c, struct varshead whereweare += (len + 3); if (!var) - var = alloca(VAR_BUF_SIZE); + var = ast_alloca(VAR_BUF_SIZE); /* Store variable name (and truncate) */ ast_copy_string(var, vars, len + 1); @@ -4200,7 +4200,7 @@ void pbx_substitute_variables_helper_full(struct ast_channel *c, struct varshead if (needsub) { size_t used; if (!ltmp) - ltmp = alloca(VAR_BUF_SIZE); + ltmp = ast_alloca(VAR_BUF_SIZE); pbx_substitute_variables_helper_full(c, headp, var, ltmp, VAR_BUF_SIZE - 1, &used); vars = ltmp; @@ -4209,7 +4209,7 @@ void pbx_substitute_variables_helper_full(struct ast_channel *c, struct varshead } if (!workspace) - workspace = alloca(VAR_BUF_SIZE); + workspace = ast_alloca(VAR_BUF_SIZE); workspace[0] = '\0'; @@ -4280,7 +4280,7 @@ void pbx_substitute_variables_helper_full(struct ast_channel *c, struct varshead whereweare += (len + 3); if (!var) - var = alloca(VAR_BUF_SIZE); + var = ast_alloca(VAR_BUF_SIZE); /* Store variable name (and truncate) */ ast_copy_string(var, vars, len + 1); @@ -4289,7 +4289,7 @@ void pbx_substitute_variables_helper_full(struct ast_channel *c, struct varshead if (needsub) { size_t used; if (!ltmp) - ltmp = alloca(VAR_BUF_SIZE); + ltmp = ast_alloca(VAR_BUF_SIZE); pbx_substitute_variables_helper_full(c, headp, var, ltmp, VAR_BUF_SIZE - 1, &used); vars = ltmp; @@ -4850,7 +4850,7 @@ static int handle_statechange(void *datap) return -1; } - cmpdevice = alloca(sizeof(*cmpdevice) + strlen(sc->dev)); + cmpdevice = ast_alloca(sizeof(*cmpdevice) + strlen(sc->dev)); strcpy(cmpdevice->hintdevice, sc->dev); ast_mutex_lock(&context_merge_lock);/* Hold off ast_merge_contexts_and_delete */ @@ -11046,11 +11046,9 @@ int pbx_builtin_importvar(struct ast_channel *chan, const char *data) if (channel && value && name) { /*! \todo XXX should do !ast_strlen_zero(..) of the args ? */ struct ast_channel *chan2 = ast_channel_get_by_name(channel); if (chan2) { - char *s = alloca(strlen(value) + 4); - if (s) { - sprintf(s, "${%s}", value); - pbx_substitute_variables_helper(chan2, s, tmp, sizeof(tmp) - 1); - } + char *s = ast_alloca(strlen(value) + 4); + sprintf(s, "${%s}", value); + pbx_substitute_variables_helper(chan2, s, tmp, sizeof(tmp) - 1); chan2 = ast_channel_unref(chan2); } pbx_builtin_setvar_helper(chan, name, tmp); |