shithub: dav1d

Download patch

ref: 43b10aff33d34a158a7a878469f1b5d479db7bb1
parent: 7d7b8d42388861df0b510646922268a6f5d704f5
author: Janne Grunau <[email protected]>
date: Wed Oct 17 16:35:31 EDT 2018

dav1d/ivf: return an error when fread fails

Fixes #66. Also fixes a leak of the demuxer context.

--- a/tools/dav1d.c
+++ b/tools/dav1d.c
@@ -88,8 +88,10 @@
         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);
     }
 
--- a/tools/input/ivf.c
+++ b/tools/input/ivf.c
@@ -93,8 +93,11 @@
     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;
 }