
On Fri, Sep 14, 2012 at 02:24:15PM +0800, Hu Tao wrote:
memset before virResetError will cause memory leak.
virResetError and virCopyError, which calls virResetError, will do memset properly, so we don't have to worry about it here.
--- src/util/virterror.c | 2 -- 1 file changed, 2 deletions(-)
diff --git a/src/util/virterror.c b/src/util/virterror.c index 7caa69e..46afd37 100644 --- a/src/util/virterror.c +++ b/src/util/virterror.c @@ -276,8 +276,6 @@ int virCopyLastError(virErrorPtr to) { virErrorPtr err = virLastErrorObject(); - /* We can't guarantee caller has initialized it to zero */ - memset(to, 0, sizeof(*to)); if (err) virCopyError(err, to); else
Concur with DV's NACK on this. It is the *callers* responsibility to ensure that 'to' does not have any allocations, by calling virResetError(&to) themselvs if needed. 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 :|