diff options
author | James Almer <jamrial@gmail.com> | 2021-01-06 22:19:14 +0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2021-01-07 04:14:51 +0300 |
commit | 57a8294ebfe56039e4f39533ff02708dedeaa45d (patch) | |
tree | 7a2cac8151fa13cd5fcf150ec8d3e6a68cfcbc69 /src/lib.c | |
parent | 5d7aa26e32f7cf5ae0c5a530084c1a587f162fc1 (diff) |
lib: check the integrity of the default picture allocator
Ensure both the allocator and release callbacks are pointing to the default
functions, and that no cookie was provided.
This prevents the user from configuring a mix of custom and default callbacks.
Diffstat (limited to 'src/lib.c')
-rw-r--r-- | src/lib.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -136,9 +136,17 @@ COLD int dav1d_open(Dav1dContext **const c_out, const Dav1dSettings *const s) { { goto error; } - if (c->allocator.alloc_picture_callback == dav1d_default_picture_alloc) { + + if (c->allocator.alloc_picture_callback == dav1d_default_picture_alloc && + c->allocator.release_picture_callback == dav1d_default_picture_release) + { + if (c->allocator.cookie) goto error; if (dav1d_mem_pool_init(&c->picture_pool)) goto error; c->allocator.cookie = c->picture_pool; + } else if (c->allocator.alloc_picture_callback == dav1d_default_picture_alloc || + c->allocator.release_picture_callback == dav1d_default_picture_release) + { + goto error; } /* On 32-bit systems extremely large frame sizes can cause overflows in |