[FFmpeg-devel] [PATCH v2] ffprobe: Fix memory leak
jamrial at gmail.com
Fri Jun 21 17:49:10 EEST 2019
On 6/21/2019 11:39 AM, Derek Buitenhuis wrote:
> On 21/06/2019 15:26, James Almer wrote:
>> Remove the three lines below as well before pushing. They are
>> superfluous as av_packet_unref() does the same internally.
> The documentation for av_packet_unref says it sets the 'remaining'
> fields to default values, but av_init_packet says it sets the
> 'optional' fields to default values. Not clear if they mean
> the same thing. Looking at the source, it's clear, but I prefer
> not to do that, since it encourages relying on undocumented
> - Derek
The doxy says "Unreference the buffer referenced by the packet and reset
the remaining packet fields to their default values", which means it
unrefs the AVBufferRef, and then sets the remaining fields in the packet
to default values, effectively wiping the whole struct.
av_init_packet() does indeed change only a subset of fields, as stated
by the doxy, which is why the data and size fields are set to NULL/0 in
this function right after it, as those are not touched by it.
Since you want to wipe the packet, calling av_packet_unref() on it does
a thorough job.
More information about the ffmpeg-devel