Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2020-07-17 03:49:04 +0300
committerJames Almer <jamrial@gmail.com>2020-07-22 17:42:54 +0300
commit5eb4405fc5da27583ee748268fc4e49a8c0c5b54 (patch)
treea9e3b167db208c4c4e4216a623c61bd7740dc0b2 /libavcodec/libdav1d.c
parentc40d36076ae695021505e8ca1a59a9be4009997c (diff)
avcodec/libdav1d: use av_image_get_buffer_size() to calculate frame size
Calling av_image_fill_arrays() with NULL as src argument may result in UB. Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec/libdav1d.c')
-rw-r--r--libavcodec/libdav1d.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c
index bbb3ec1e6c..132d344296 100644
--- a/libavcodec/libdav1d.c
+++ b/libavcodec/libdav1d.c
@@ -66,12 +66,11 @@ static int libdav1d_picture_allocator(Dav1dPicture *p, void *cookie)
{
Libdav1dContext *dav1d = cookie;
enum AVPixelFormat format = pix_fmt[p->p.layout][p->seq_hdr->hbd];
- int ret, linesize[4], h = FFALIGN(p->p.h, 128);
+ int ret, linesize[4], h = FFALIGN(p->p.h, 128), w = FFALIGN(p->p.w, 128);
uint8_t *aligned_ptr, *data[4];
AVBufferRef *buf;
- ret = av_image_fill_arrays(data, linesize, NULL, format, FFALIGN(p->p.w, 128),
- h, DAV1D_PICTURE_ALIGNMENT);
+ ret = av_image_get_buffer_size(format, w, h, DAV1D_PICTURE_ALIGNMENT);
if (ret < 0)
return ret;
@@ -94,7 +93,8 @@ static int libdav1d_picture_allocator(Dav1dPicture *p, void *cookie)
// Use the extra DAV1D_PICTURE_ALIGNMENT padding bytes in the buffer to align it
// if required.
aligned_ptr = (uint8_t *)FFALIGN((uintptr_t)buf->data, DAV1D_PICTURE_ALIGNMENT);
- ret = av_image_fill_pointers(data, format, h, aligned_ptr, linesize);
+ ret = av_image_fill_arrays(data, linesize, aligned_ptr, format, w, h,
+ DAV1D_PICTURE_ALIGNMENT);
if (ret < 0) {
av_buffer_unref(&buf);
return ret;