don't crash when asked to read from a file that doesn't exist (issue #6786)

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@14462 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Russell Bryant
2006-03-23 20:13:48 +00:00
parent b0f4874196
commit 9884c9637a

View File

@@ -95,7 +95,7 @@ static int readfile_exec(struct ast_channel *chan, void *data)
}
}
returnvar = ast_read_textfile(file);
if ((returnvar = ast_read_textfile(file))) {
if (len > 0) {
if (len < strlen(returnvar))
returnvar[len]='\0';
@@ -104,6 +104,7 @@ static int readfile_exec(struct ast_channel *chan, void *data)
}
pbx_builtin_setvar_helper(chan, varname, returnvar);
free(returnvar);
}
LOCAL_USER_REMOVE(u);
return res;
}