[libvirt] [PATCH] daemon: Don't try to free an unsigned int in error paths
Christophe Fergeau
cfergeau at redhat.com
Fri Apr 22 16:31:25 UTC 2011
On Fri, Apr 22, 2011 at 10:17:01AM -0600, Eric Blake wrote:
> On 04/22/2011 10:11 AM, Matthias Bolte wrote:
> > remoteDispatchError(rerr);
> > - VIR_FREE(ret->names.names_len);
> > + VIR_FREE(ret->names.names_val);
>
> And to think I missed those in the huge patch. Oops.
Maybe VIR_FREE should be changed to something like
-# define VIR_FREE(ptr) virFree(&(ptr))
+# define VIR_FREE(ptr) \
+ do { void *check_type = (ptr); virFree(&(check_type)); } while (0)
so that the compiler can warn about such issues?
With this change, I get
remote.c: In function 'remoteDispatchListInterfaces':
remote.c:3978:33: warning: initialization makes pointer from integer
without a cast [enabled by default]
I also get more warnings about casting from const to non-const, this can
be avoided by making check_type const void *, but maybe these warnings
indicate that something that shouldn't be freed is freed.
Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110422/96f4c16e/attachment-0001.sig>
More information about the libvir-list
mailing list