[vlc-devel] [vlc-commits] decoder: add Destroy helper function for decoder owners

Steve Lhomme robux4 at ycbcr.xyz
Tue Feb 19 08:13:36 CET 2019

On 19/02/2019 08:03, Jean-Baptiste Kempf wrote:
> Hello,
> On Tue, 19 Feb 2019, at 08:01, Steve Lhomme wrote:
>>   > I really prefer having a crash (via assert/ASAN) when a client is
>> misusing an API (calling Destroy with a freed pointer) instead of
>> ignoring it.
>> This is true when calling Destroy twice is a bug. It isn't with this
> Then assert() it.

I'm not sure I'm following. Would you assert when calling 
decoder_Destroy() with a NULL decoder (meaning it doesn't exist at all, 
not even been through decoder_Init) ? Or in the solution I removed where 
you'd call decoder_Destroy() with a holder than has been emptied, which 
is not a bug at all.

Or you mean assert when decoder_Destroy() is passed an already freed 
pointer ? In which case no assert will help detect a double free.

As a more general remark, I think it's odd that rather than removing a 
class of bugs, we prefer to keep it and rely on tools to find them for 
us, when they eventually occur.

> This is not a libVLC API, where you need to deal with invalid input, and where assert is not enough.
> -- 
> Jean-Baptiste Kempf -  President
> +33 672 704 734
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel

More information about the vlc-devel mailing list