[FFmpeg-cvslog] examples: Add av_freep to avoid potential memory leak
Jiasheng Jiang
git at videolan.org
Mon Aug 4 19:38:34 EEST 2025
ffmpeg | branch: release/6.1 | Jiasheng Jiang <jiashengjiangcool at gmail.com> | Sat Aug 2 23:28:48 2025 +0000| [9f7b46e6d9f17732712d936e57c9223319be4064] | committer: Michael Niedermayer
examples: Add av_freep to avoid potential memory leak
Add av_freep() to free avio_ctx_buffer if avio_alloc_context fails
to avoid potential memory leak.
Fixes: 5fc4dea39c ("examples: add avio_reading.c example")
Signed-off-by: Jiasheng Jiang <jiashengjiangcool at gmail.com>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
(cherry picked from commit 9ca58424ded24e931fed329174c28244b67d5670)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9f7b46e6d9f17732712d936e57c9223319be4064
---
doc/examples/avio_read_callback.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/doc/examples/avio_read_callback.c b/doc/examples/avio_read_callback.c
index 4cf81ad72e..aa4a5c5b85 100644
--- a/doc/examples/avio_read_callback.c
+++ b/doc/examples/avio_read_callback.c
@@ -95,6 +95,7 @@ int main(int argc, char *argv[])
avio_ctx = avio_alloc_context(avio_ctx_buffer, avio_ctx_buffer_size,
0, &bd, &read_packet, NULL, NULL);
if (!avio_ctx) {
+ av_freep(&avio_ctx_buffer);
ret = AVERROR(ENOMEM);
goto end;
}
More information about the ffmpeg-cvslog
mailing list