ref: a8d24ea168ba579152758552b5beb48d08b19b11
parent: c5d283bd8c298143188e454e47a2ce78acc5f265
author: Janne Grunau <janne-vlc@jannau.net>
date: Wed Oct 3 12:48:44 EDT 2018
API: always unref input buffer after consuming it completely
--- a/src/lib.c
+++ b/src/lib.c
@@ -196,8 +196,8 @@
assert(res <= in->sz);
in->sz -= res;
in->data += res;
+ if (!in->sz) dav1d_data_unref(in);
if (c->out.data[0]) {
- if (!in->sz) dav1d_data_unref(in);
dav1d_picture_ref(out, &c->out);
dav1d_picture_unref(&c->out);
return 0;
--- a/tests/libfuzzer/dav1d_fuzzer.c
+++ b/tests/libfuzzer/dav1d_fuzzer.c
@@ -72,11 +72,8 @@
err = dav1d_decode(ctx, &buf, &pic);
if (err == 0) {
dav1d_picture_unref(&pic);
- } else {
- if (!buf.sz) dav1d_data_unref(&buf);
- if (err != -EAGAIN) {
- break;
- }
+ } else if (err != -EAGAIN) {
+ break;
}
} while (buf.sz > 0);