diff mbox series

[FFmpeg-devel,v3,4/4] libavutil/imgutils: check for non-null buffer in av_image_fill_pointers

Message ID d23daf61cc098edf621fba29110786191ea0e64d.1594660141.git.bkkim@google.com
State New
Headers show
Series [FFmpeg-devel,v3,1/4] libavutil/imgutils: add utility to get plane sizes
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Brian Kim July 13, 2020, 5:09 p.m. UTC
We were previously always filling data by adding offsets to ptr, which
was undefined behavior when ptr was NULL.

Signed-off-by: Brian Kim <bkkim@google.com>
---
 libavutil/imgutils.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c
index 345b7fa94c..721dc2784a 100644
--- a/libavutil/imgutils.c
+++ b/libavutil/imgutils.c
@@ -166,6 +166,9 @@  int av_image_fill_pointers(uint8_t *data[4], enum AVPixelFormat pix_fmt, int hei
 
     memset(data , 0, sizeof(data[0])*4);
 
+    if (!ptr)
+        return ret;
+
     data[0] = ptr;
     for (i = 1; i < 4 && sizes[i - 1] > 0; i++)
         data[i] = data[i - 1] + sizes[i - 1];