On Thu, Jul 25, 2019 at 10:13:11AM +0100, Peter Maydell wrote:
> On Tue, 23 Jul 2019 at 16:49, Daniel P. Berrangé <berra...@redhat.com> wrote:
> >
> > Both GCC and CLang support a C extension attribute((cleanup)) which
> > allows you to define a function that is invoked when a stack variable
> > exits scope. This typically used to free the memory allocated to it,
> > though you're not restricted to this. For example it could be used to
> > unlock a mutex.
> 
> Does Coverity handle this? Can it be made to wire up this kind
> of deallocation into checks of use-after-free/memory leaks/etc?

I believe so, in so much as it has not complained about leaks in
libvirt where we've removed the free() calls in favour of the
attribute(cleanup) annotations. I'm presuming this is because the
free() calls do still exist - they're simply automatically added
in all paths that exist a code scope. You can still see the free()
calls in GDB stack traces for example.

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

Reply via email to