]> git.ipfire.org Git - thirdparty/libvirt.git/commit
remote: avoid null dereference on error
authorEric Blake <eblake@redhat.com>
Tue, 3 May 2011 17:24:23 +0000 (11:24 -0600)
committerEric Blake <eblake@redhat.com>
Wed, 4 May 2011 16:55:29 +0000 (10:55 -0600)
commit85cb2926814b34dca9d44ffe378ca99add65e466
tree371ce72279e0f286f9c7579348ad6fa361a77230
parentd0a8f99c75ec927064713ee70f5779fe36f4eed7
remote: avoid null dereference on error

Clang found three instances of uninitialized use of nparams in
the cleanup path.  Unfortunately, one is a false positive: clang
couldn't see that ret->params.params_val is guaranteed to be
NULL unless allocated within a function, and that nparams is
guaranteed to be assigned prior to the allocation; hoisting the
assignment to nparams to be earlier in the function shuts up
that false positive.  But two of the reports also happened to
highlight a real bug - the error path can dereference NULL.

Regression introduced in commit 158ba873.

* daemon/remote.c (remoteDispatchDomainGetMemoryParameters)
(remoteDispatchDomainGetBlkioParameters): Don't clear fields if
array was not allocated.
(remoteDispatchDomainGetSchedulerParameters): Initialize nparams
earlier.
daemon/remote.c