ffmpeg | branch: release/7.0 | Jiasheng Jiang <jiashengjiangc...@gmail.com> | 
Sun Aug  3 20:32:23 2025 +0000| [8aed34f920f4994e8d0676d2e3eba6b74cf640a8] | 
committer: Michael Niedermayer

libavcodec/tests/motion: Add check for avcodec_alloc_context3()

Add check for the return value of avcodec_alloc_context3() to avoid potential 
NULL pointer dereference.

Fixes: 5d48e4eafa ("Merge commit 'a6a750c7ef240b72ce01e9653343a0ddf247d196'")
Signed-off-by: Jiasheng Jiang <jiashengjiangc...@gmail.com>
Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc>
(cherry picked from commit 55d234b4330d1588eb127cf2283a442ee341f2c2)
Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8aed34f920f4994e8d0676d2e3eba6b74cf640a8
---

 libavcodec/tests/motion.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/tests/motion.c b/libavcodec/tests/motion.c
index caa8ecb8be..dca6aada22 100644
--- a/libavcodec/tests/motion.c
+++ b/libavcodec/tests/motion.c
@@ -129,6 +129,10 @@ int main(int argc, char **argv)
     printf("ffmpeg motion test\n");
 
     ctx = avcodec_alloc_context3(NULL);
+    if (!ctx) {
+        return 1;
+    }
+
     ctx->flags |= AV_CODEC_FLAG_BITEXACT;
     av_force_cpu_flags(0);
     memset(&cctx, 0, sizeof(cctx));

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

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

Reply via email to