From ddea126b43ee118eec4d745c634168273e3605a7 Mon Sep 17 00:00:00 2001 From: tilghman Date: Sun, 19 Feb 2006 17:11:02 +0000 Subject: Bug 6539 - Division by two negates error flag git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.2@10462 f38db490-d61c-443f-a65b-d21fe96a405b --- formats/format_sln.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'formats/format_sln.c') diff --git a/formats/format_sln.c b/formats/format_sln.c index 008a715bc..c1a16618d 100644 --- a/formats/format_sln.c +++ b/formats/format_sln.c @@ -172,6 +172,7 @@ static int slinear_write(struct ast_filestream *fs, struct ast_frame *f) static int slinear_seek(struct ast_filestream *fs, long sample_offset, int whence) { off_t offset=0,min,cur,max; + int res; min = 0; sample_offset <<= 1; @@ -189,7 +190,12 @@ static int slinear_seek(struct ast_filestream *fs, long sample_offset, int whenc } /* always protect against seeking past begining. */ offset = (offset < min)?min:offset; - return fseek(fs->f, offset, SEEK_SET) / 2; + res = fseek(fs->f, offset, SEEK_SET); + /* Negative values indicate error */ + if (res > -1) + return res / 2; + else + return res; } static int slinear_trunc(struct ast_filestream *fs) -- cgit v1.2.3