[FFmpeg-trac] #7858(avformat:new): Incorrect function used in the avio_reading.c example
FFmpeg
trac at avcodec.org
Fri Apr 19 20:07:34 EEST 2019
#7858: Incorrect function used in the avio_reading.c example
-------------------------------------+-------------------------------------
Reporter: Ferneu | Type: defect
Status: new | Priority: minor
Component: avformat | Version: git-
Keywords: | master
AVIOContext, avio_context_free, | Blocked By:
buffer |
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
-------------------------------------+-------------------------------------
The avio_reading.c example uses `av_freep()` to free the `AVIOContext` it
allocated with `avio_alloc_context()`
I believe it should be using `avio_context_free()` instead.
And while we are at it, you guys should really consider completely
removing the buffer `avio_alloc_context()` requires/allow the user to
pass. Since according to the docs the `AVIOContext` is free to reallocate
that buffer at will and, in my experience, it usually does that, the user
always ends up with a dangling pointer in case he was hoping to perform
some sane resource management (i.e., free the things he allocated).
The "correct" way to free the `AVIOContext` (first call
`av_freep(&avio_ctx->buffer)` and then free the context itself) is not
intuitive at all, and since you guys already have `avio_context_free()`,
you should make it take care of doing that.
--
Ticket URL: <https://trac.ffmpeg.org/ticket/7858>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list