aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_readfile.c
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-03-23 20:15:01 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-03-23 20:15:01 +0000
commit9402c54f97a3243e14735ac5596439eca9724302 (patch)
tree60deb7c36c8ad08b7a67473868abcce43aeb49d6 /apps/app_readfile.c
parent421a7bdbd9459baa81d93363c51f8bf3ed0055ba (diff)
Merged revisions 14462 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2 ........ r14462 | russell | 2006-03-23 15:13:48 -0500 (Thu, 23 Mar 2006) | 2 lines don't crash when asked to read from a file that doesn't exist (issue #6786) ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@14463 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_readfile.c')
-rw-r--r--apps/app_readfile.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/apps/app_readfile.c b/apps/app_readfile.c
index 4b3f57e94..708ad02f3 100644
--- a/apps/app_readfile.c
+++ b/apps/app_readfile.c
@@ -92,15 +92,16 @@ static int readfile_exec(struct ast_channel *chan, void *data)
}
}
- returnvar = ast_read_textfile(file);
- if(len > 0){
- if(len < strlen(returnvar))
- returnvar[len]='\0';
- else
- ast_log(LOG_WARNING,"%s is longer than %d, and %d \n", file, len, (int)strlen(returnvar));
+ if ((returnvar = ast_read_textfile(file))) {
+ if (len > 0) {
+ if (len < strlen(returnvar))
+ returnvar[len]='\0';
+ else
+ ast_log(LOG_WARNING, "%s is longer than %d, and %d \n", file, len, (int)strlen(returnvar));
+ }
+ pbx_builtin_setvar_helper(chan, varname, returnvar);
+ free(returnvar);
}
- pbx_builtin_setvar_helper(chan, varname, returnvar);
- free(returnvar);
LOCAL_USER_REMOVE(u);
return res;
}