[FFmpeg-devel] [PATCH v2 2/3] avformat/hashenc: use an array of hashes
    James Almer 
    jamrial at gmail.com
       
    Wed Sep 11 17:03:36 EEST 2019
    
    
  
On 9/11/2019 10:53 AM, Moritz Barsnick wrote:
> On Wed, Sep 11, 2019 at 10:39:40 -0300, James Almer wrote:
>> On 9/11/2019 10:34 AM, Moritz Barsnick wrote:
>>> +static void hash_free(struct AVFormatContext *s)
>>> +{
>>> +    struct HashContext *c = s->priv_data;
>>> +    av_hash_freep(&c->hashes[0]);
>>
>> AVOutputFormat.deinit() is called when AVOutputFormat.init() fails, so
>> c->hashes can be NULL. same with the framehash muxer.
>>
>>> +    av_freep(&c->hashes);
>>> +}
> 
> Does this mean there should just be a check for "if (c->hashes)" here,
> or can the suggestion in
> http://ffmpeg.org/pipermail/ffmpeg-devel/2019-August/248014.html
> actually not be implemented? No common freeing function?
av_freep() can be used with NULL variables without issues. The problem
is that you're dereferencing c->hashes for the av_hash_freep() call. If
it's NULL, you'll get a segfault. So just do
if (c->hashes)
    av_hash_freep(&c->hashes[0]);
av_freep(&c->hashes);
In both muxers. Then adapt it in PATCH 3/3 for the streamhash muxer
addition.
> 
> Thanks,
> Moritz
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
> 
    
    
More information about the ffmpeg-devel
mailing list