[FFmpeg-devel] [PATCH v2] doc/examples/vaapi_encode: Try to check fwrite() for failure

Michael Niedermayer michael at niedermayer.cc
Tue Jul 2 02:47:33 EEST 2024


Fixes: CID1604548 Unused value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
 doc/examples/vaapi_encode.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/doc/examples/vaapi_encode.c b/doc/examples/vaapi_encode.c
index d5f472f6dd8..ff3ebb1e2b8 100644
--- a/doc/examples/vaapi_encode.c
+++ b/doc/examples/vaapi_encode.c
@@ -88,6 +88,10 @@ static int encode_write(AVCodecContext *avctx, AVFrame *frame, FILE *fout)
         enc_pkt->stream_index = 0;
         ret = fwrite(enc_pkt->data, enc_pkt->size, 1, fout);
         av_packet_unref(enc_pkt);
+        if (ret != enc_pkt->size) {
+            ret = AVERROR(errno);
+            break;
+        }
     }
 
 end:
-- 
2.45.2



More information about the ffmpeg-devel mailing list