file: properly forward errors from file_read() and file_write()

Bug-Id: 881

CC: libav-stable@libav.org

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
This commit is contained in:
Sean McGovern 2015-08-27 00:04:15 -04:00 committed by Luca Barbato
parent 5a1a9da8a7
commit e05f7ed543
1 changed files with 4 additions and 2 deletions

View File

@ -59,13 +59,15 @@ static const AVClass file_class = {
static int file_read(URLContext *h, unsigned char *buf, int size)
{
FileContext *c = h->priv_data;
return read(c->fd, buf, size);
int ret = read(c->fd, buf, size);
return (ret == -1) ? AVERROR(errno) : ret;
}
static int file_write(URLContext *h, const unsigned char *buf, int size)
{
FileContext *c = h->priv_data;
return write(c->fd, buf, size);
int ret = write(c->fd, buf, size);
return (ret == -1) ? AVERROR(errno) : ret;
}
static int file_get_handle(URLContext *h)