X-Git-Url: http://git.asterisk.org/gitweb/?p=asterisk%2Fasterisk.git;a=blobdiff_plain;f=formats%2Fformat_h263.c;h=ec08867d8b3826573813af5d2dd6f46c993f255a;hp=b00ae0fb30e8e857177cb99dda78ee0c026c10e6;hb=ba7032be5f4ac8c638806fe6d4f683ec7813c82f;hpb=ba0f044bde5e5417cec7c3daf2bed907224423e6;ds=sidebyside diff --git a/formats/format_h263.c b/formats/format_h263.c index b00ae0f..ec08867 100644 --- a/formats/format_h263.c +++ b/formats/format_h263.c @@ -146,10 +146,19 @@ static int h263_seek(struct ast_filestream *fs, off_t sample_offset, int whence) static int h263_trunc(struct ast_filestream *fs) { - /* Truncate file to current length */ - if (ftruncate(fileno(fs->f), ftello(fs->f)) < 0) + int fd; + off_t cur; + + if ((fd = fileno(fs->f)) < 0) { + ast_log(AST_LOG_WARNING, "Unable to determine file descriptor for h263 filestream %p: %s\n", fs, strerror(errno)); return -1; - return 0; + } + if ((cur = ftello(fs->f) < 0)) { + ast_log(AST_LOG_WARNING, "Unable to determine current position in h263 filestream %p: %s\n", fs, strerror(errno)); + return -1; + } + /* Truncate file to current length */ + return ftruncate(fd, cur); } static off_t h263_tell(struct ast_filestream *fs)