As the potential failure of the av_malloc(), the av_memdup()
could return NULL if fails.
Therefore, it should be better to check it and return error
if fails, like the av_buffer_ref().

Fixes: 535a835e51 ("ffmpeg: use display matrix frame side data for 
autorotation")
Signed-off-by: Jiasheng Jiang <jiash...@iscas.ac.cn>
---
 fftools/ffmpeg_filter.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 2c3f21985f..cdaa0d8165 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1161,8 +1161,11 @@ int ifilter_parameters_from_frame(InputFilter *ifilter, 
const AVFrame *frame)
 
     av_freep(&ifilter->displaymatrix);
     sd = av_frame_get_side_data(frame, AV_FRAME_DATA_DISPLAYMATRIX);
-    if (sd)
+    if (sd) {
         ifilter->displaymatrix = av_memdup(sd->data, sizeof(int32_t) * 9);
+        if (!ifilter->displaymatrix)
+            return AVERROR(ENOMEM);
+    }
 
     if (frame->hw_frames_ctx) {
         ifilter->hw_frames_ctx = av_buffer_ref(frame->hw_frames_ctx);
-- 
2.25.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to