aboutsummaryrefslogtreecommitdiffstats
path: root/funcs
diff options
context:
space:
mode:
authormmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2008-12-22 16:17:17 +0000
committermmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2008-12-22 16:17:17 +0000
commit4829f23e6f63090bf15f720d0bfdc9d548061780 (patch)
tree9305a977f4809a1c376b19add6648a2130f2c754 /funcs
parentbec885e9cdfc2a633539b6938f6465fbc2355bd2 (diff)
Merged revisions 166267 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ........ r166267 | mmichelson | 2008-12-22 10:07:59 -0600 (Mon, 22 Dec 2008) | 17 lines Fix a file playback crash and explicitly initialize values in func_timeout.c A crash was brought up on the bugtracker. The first run through valgrind was full of legitimate complaints of uninitialized values in func_timeout when setting a response timeout. These were fixed but the crash persisted. A second run through showed the real problem. The reference counting used for filestreams was incorrect because there were some missing increments when a frame was read from a format module. (closes issue #14118) Reported by: blitzrage Patches: 14118v2.patch uploaded by putnopvut (license 60) Tested by: blitzrage ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.1@166275 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'funcs')
-rw-r--r--funcs/func_timeout.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/funcs/func_timeout.c b/funcs/func_timeout.c
index 625070217..1640334fc 100644
--- a/funcs/func_timeout.c
+++ b/funcs/func_timeout.c
@@ -83,11 +83,12 @@ static int timeout_read(struct ast_channel *chan, const char *cmd, char *data,
static int timeout_write(struct ast_channel *chan, const char *cmd, char *data,
const char *value)
{
- double x;
- long sec;
+ double x = 0.0;
+ long sec = 0L;
char timestr[64];
struct ast_tm myt;
- struct timeval when;
+ struct timeval when = {0,};
+ int res;
if (!chan)
return -1;
@@ -100,9 +101,13 @@ static int timeout_write(struct ast_channel *chan, const char *cmd, char *data,
if (!value)
return -1;
- if ((sscanf(value, "%ld%lf", &sec, &x) == 0) || sec < 0)
+ res = sscanf(value, "%ld%lf", &sec, &x);
+ if (res == 0 || sec < 0) {
when.tv_sec = 0;
- else {
+ when.tv_usec = 0;
+ } else if (res == 1) {
+ when.tv_sec = sec;
+ } else if (res == 2) {
when.tv_sec = sec;
when.tv_usec = x * 1000000;
}