summaryrefslogtreecommitdiff
path: root/main/file.c
diff options
context:
space:
mode:
authorKinsey Moore <kmoore@digium.com>2012-07-31 20:21:43 +0000
committerKinsey Moore <kmoore@digium.com>2012-07-31 20:21:43 +0000
commit9b16c8b0f6c3b6310e303411421bfcb16b26c3c4 (patch)
tree273c31a834a21bd2239ec6b83cd35c602ea25d26 /main/file.c
parent6c23a60f802e7708389b1a6463a40dc0500512bd (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/file.c')
-rw-r--r--main/file.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/main/file.c b/main/file.c
index 3f52e0aab..4c25b987a 100644
--- a/main/file.c
+++ b/main/file.c
@@ -689,9 +689,7 @@ struct ast_filestream *ast_openstream_full(struct ast_channel *chan, const char
if (preflang == NULL)
preflang = "";
buflen = strlen(preflang) + strlen(filename) + 4;
- buf = alloca(buflen);
- if (buf == NULL)
- return NULL;
+ buf = ast_alloca(buflen);
if (!(file_fmt_cap = ast_format_cap_alloc_nolock())) {
return NULL;
@@ -735,9 +733,7 @@ struct ast_filestream *ast_openvstream(struct ast_channel *chan, const char *fil
if (preflang == NULL)
preflang = "";
buflen = strlen(preflang) + strlen(filename) + 4;
- buf = alloca(buflen);
- if (buf == NULL)
- return NULL;
+ buf = ast_alloca(buflen);
/* is the channel capable of video without translation ?*/
if (!ast_format_cap_has_type(ast_channel_nativeformats(chan), AST_FORMAT_TYPE_VIDEO)) {
@@ -987,9 +983,7 @@ int ast_fileexists(const char *filename, const char *fmt, const char *preflang)
if (preflang == NULL)
preflang = "";
buflen = strlen(preflang) + strlen(filename) + 4; /* room for everything */
- buf = alloca(buflen);
- if (buf == NULL)
- return 0;
+ buf = ast_alloca(buflen);
return fileexists_core(filename, fmt, preflang, buf, buflen, NULL) ? 1 : 0;
}
@@ -1168,7 +1162,7 @@ struct ast_filestream *ast_writefile(const char *filename, const char *type, con
*c = '_';
size = strlen(fn) + strlen(record_cache_dir) + 2;
- buf = alloca(size);
+ buf = ast_alloca(size);
strcpy(buf, record_cache_dir);
strcat(buf, "/");
strcat(buf, fn);