Il mar 25 apr 2023, 15:31 Daniel P. Berrangé <berra...@redhat.com> ha scritto:
> > > - BHListSlice slice; > > > + /* > > > + * gcc13 complains about putting a local variable > > > + * in a global list, so put it on the heap. > > > + */ > > > + g_autofree BHListSlice *slice = g_new(BHListSlice, 1); > > > BHListSlice *s; > > > int ret = 0; > > > > > > > This must be a memory leak since you're adding a g_new but not > > adding any g_free > > Sorry, I'm failing to read properly today. It uses g_autofree > so there is no leak. > On the other hand, if the pointer to the heap-allocated BHListSlice escaped, this would be a dangling pointer as well—just not the kind that the new GCC warning can report. So this patch is also doing nothing but shut up the compiler; but it's doing so in an underhanded manner and with a runtime cost, and as such it's worse than Cedric's patch. Paolo > With 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 :| > >