Commit 43b10aff authored by Janne Grunau's avatar Janne Grunau Committed by Ronald S. Bultje

dav1d/ivf: return an error when fread fails

Fixes #66. Also fixes a leak of the demuxer context.
parent 7d7b8d42
......@@ -88,8 +88,10 @@ int main(const int argc, char *const *const argv) {
return res;
}
for (unsigned i = 0; i <= cli_settings.skip; i++) {
if ((res = input_read(in, &data)) < 0)
if ((res = input_read(in, &data)) < 0) {
input_close(in);
return res;
}
if (i < cli_settings.skip) dav1d_data_unref(&data);
}
......
......@@ -93,8 +93,11 @@ static int ivf_read(IvfInputContext *const c, Dav1dData *const buf) {
fseek(c->f, 8, SEEK_CUR); // skip timestamp
const ptrdiff_t sz = rl32(data);
dav1d_data_create(buf, sz);
if ((res = fread(buf->data, sz, 1, c->f)) != 1)
if ((res = fread(buf->data, sz, 1, c->f)) != 1) {
fprintf(stderr, "Failed to read frame data: %s\n", strerror(errno));
dav1d_data_unref(buf);
return -1;
}
return 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment