mirror of
https://mirror.skon.top/https://github.com/FFmpeg/FFmpeg
synced 2026-04-20 21:00:41 +08:00
doc/examples/remux: fix NULL pointer dereference in cleanup
The cleanup path uses `ofmt->flags` to check AVFMT_NOFILE, but `ofmt` is only assigned after avformat_alloc_output_context2 succeeds. If a failure occurs between output context allocation and the `ofmt` assignment (e.g. stream_mapping allocation fails), ofmt_ctx is non-NULL while ofmt is still NULL, causing a crash. Use ofmt_ctx->oformat->flags instead, which is always valid when ofmt_ctx is non-NULL. Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
This commit is contained in:
@@ -184,7 +184,7 @@ end:
|
||||
avformat_close_input(&ifmt_ctx);
|
||||
|
||||
/* close output */
|
||||
if (ofmt_ctx && !(ofmt->flags & AVFMT_NOFILE))
|
||||
if (ofmt_ctx && !(ofmt_ctx->oformat->flags & AVFMT_NOFILE))
|
||||
avio_closep(&ofmt_ctx->pb);
|
||||
avformat_free_context(ofmt_ctx);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user