ref: e72bec43b19f932bd1f95210fe4208e7d725abc9
parent: ceb6175d66324777254f78eaf6c8cf39527ed617
author: Janne Grunau <janne-vlc@jannau.net>
date: Sat Dec 8 09:10:32 EST 2018
dav1d_open: free context completely on allocation errors
--- a/src/lib.c
+++ b/src/lib.c
@@ -157,11 +157,21 @@
error:
if (c) {
if (c->fc) {
- for (unsigned n = 0; n < c->n_fc; n++)
- if (c->fc[n].tc)
+ for (unsigned n = 0; n < c->n_fc; n++) {
+ if (c->fc[n].tc) {
+ for (int m = 0; m < s->n_tile_threads; m++) {
+ Dav1dTileContext *const t = &c->fc[n].tc[m];
+ dav1d_free_aligned(t->cf);
+ dav1d_free_aligned(t->scratch.mem);
+ dav1d_free_aligned(t->emu_edge);
+ }
dav1d_free_aligned(c->fc[n].tc);
+ }
+ if (c->fc[n].libaom_cm) av1_free_ref_mv_common(c->fc[n].libaom_cm);
+ }
dav1d_free_aligned(c->fc);
}
+ if (c->n_fc > 1) free(c->frame_thread.out_delayed);
dav1d_freep_aligned(c_out);
}
fprintf(stderr, "Failed to allocate memory: %s\n", strerror(errno));