This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit 1cf02df1229f13a87e8498f8b34e41dc13d82887
Author:     Jun Zhao <[email protected]>
AuthorDate: Sun Mar 8 22:49:38 2026 +0800
Commit:     toots <[email protected]>
CommitDate: Wed Mar 18 02:08:09 2026 +0000

    doc/examples/decode_video: check fopen return value in pgm_save
    
    pgm_save() passes the FILE pointer from fopen() directly to
    fprintf() and fwrite() without a NULL check. If fopen() fails
    (e.g. permission denied or disk full), this causes a NULL pointer
    dereference and crash.
    
    Signed-off-by: Jun Zhao <[email protected]>
---
 doc/examples/decode_video.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/doc/examples/decode_video.c b/doc/examples/decode_video.c
index b0b3a6ae92..9d92ebbe9c 100644
--- a/doc/examples/decode_video.c
+++ b/doc/examples/decode_video.c
@@ -42,7 +42,11 @@ static void pgm_save(unsigned char *buf, int wrap, int 
xsize, int ysize,
     FILE *f;
     int i;
 
-    f = fopen(filename,"wb");
+    f = fopen(filename, "wb");
+    if (!f) {
+        fprintf(stderr, "Could not open %s\n", filename);
+        return;
+    }
     fprintf(f, "P5\n%d %d\n%d\n", xsize, ysize, 255);
     for (i = 0; i < ysize; i++)
         fwrite(buf + i * wrap, 1, xsize, f);

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to