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@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
> 

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to