[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt PATCH 3/3] util: bitmap: use g_new0/g_free



On Mon, Aug 03, 2020 at 07:29:19PM +0200, Peter Krempa wrote:
> On Mon, Aug 03, 2020 at 19:18:53 +0200, Ján Tomko wrote:
> > Signed-off-by: Ján Tomko <jtomko redhat com>
> > ---
> >  src/util/virbitmap.c | 20 ++++++--------------
> >  1 file changed, 6 insertions(+), 14 deletions(-)
> > 
> > diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
> > index 4c205016ff..f7dd5d05ad 100644
> > --- a/src/util/virbitmap.c
> > +++ b/src/util/virbitmap.c
> 
> [...]
> 
> > @@ -126,10 +121,9 @@ virBitmapNewEmpty(void)
> >  void
> >  virBitmapFree(virBitmapPtr bitmap)
> >  {
> > -    if (bitmap) {
> > -        VIR_FREE(bitmap->map);
> > -        VIR_FREE(bitmap);
> > -    }
> > +    if (bitmap)
> > +        g_free(bitmap->map);
> 
> Preferrably keep this VIR_FREE or it's expansion to g_clear_pointer. If
> a caller uses a stale pointer, it will crash on dereferencing this part.

There's no strong reason to do that in a vir*Free() function, since
'bitmap' itself is being freed. 


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 :|


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]