On Thu, Mar 27, 2014 at 04:39:28PM +0530, Nehal J Wani wrote: > > This doesn't look at all right either. If nmachines is 0, then machines > > should already be NULL. > > > > If you look at the code of virQEMUCapsGetMachineTypesCaps, you see: > int virQEMUCapsGetMachineTypesCaps(virQEMUCapsPtr qemuCaps, > size_t *nmachines, > virCapsGuestMachinePtr **machines) > { > size_t i; > > *nmachines = 0; > *machines = NULL; > if (VIR_ALLOC_N(*machines, qemuCaps->nmachineTypes) < 0) > goto error; > *nmachines = qemuCaps->nmachineTypes; > > Even if we pass nmachines=0 to VIR_ALLOC_N , it emulates GNU behavior > of malloc(0) allocating a pointer, which is never freed, and hence > needs a VIR_FREE. IMHO we should fix that code so it doesn't allocate the machines array. ie we shouldn't require callers to free data that they're not expecting to be allocated in the first place Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list