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 /funcs/func_cut.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 'funcs/func_cut.c')
-rw-r--r-- | funcs/func_cut.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/funcs/func_cut.c b/funcs/func_cut.c index 762dd61fe..4b6dc9d48 100644 --- a/funcs/func_cut.c +++ b/funcs/func_cut.c @@ -119,7 +119,7 @@ static int sort_internal(struct ast_channel *chan, char *data, char *buffer, siz count++; } - sortable_keys = alloca(count * sizeof(struct sortable_keys)); + sortable_keys = ast_alloca(count * sizeof(struct sortable_keys)); memset(sortable_keys, 0, count * sizeof(struct sortable_keys)); @@ -170,9 +170,8 @@ static int cut_internal(struct ast_channel *chan, char *data, struct ast_str **b /* Check arguments */ if (args.argc < 3) { return ERROR_NOARG; - } else if (!(var_expr = alloca(strlen(args.varname) + 4))) { - return ERROR_NOMEM; } + var_expr = ast_alloca(strlen(args.varname) + 4); /* Get the value of the variable named in the 1st argument */ snprintf(var_expr, strlen(args.varname) + 4, "${%s}", args.varname); |