diff --git a/doc/examples/avio_reading.c b/doc/examples/avio_reading.c index 45dbd4725a..02474e907a 100644 --- a/doc/examples/avio_reading.c +++ b/doc/examples/avio_reading.c @@ -119,8 +119,10 @@ int main(int argc, char *argv[]) end: avformat_close_input(&fmt_ctx); /* note: the internal buffer could have changed, and be != avio_ctx_buffer */ - av_freep(&avio_ctx->buffer); - av_freep(&avio_ctx); + if (avio_ctx) { + av_freep(&avio_ctx->buffer); + av_freep(&avio_ctx); + } av_file_unmap(buffer, buffer_size); if (ret < 0) {