[libvirt] [PATCH] More paranoid initialization of 'nparams' variable in dispatch code

Eric Blake eblake at redhat.com
Thu May 2 13:48:35 UTC 2013


On 05/02/2013 05:39 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange at redhat.com>
> 
> Since the 'nparams' variable passed to virTypedParametersFree is
> supposed to represent the size of the 'params' array, it is bad
> practice to initialize it to a non-zero value, until the array
> has been allocated.

Thankfully, virTypedParamsFree() does nothing when passed a NULL params
pointer, regardless of the size of nparams, so we had no real bug here;
but I agree that it is wiser to be robust against any future changes in
the code.

> 
> Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
> ---
>  daemon/remote.c | 78 ++++++++++++++++++++++++++++++++-------------------------
>  1 file changed, 44 insertions(+), 34 deletions(-)

ACK.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130502/c99ca816/attachment-0001.sig>


More information about the libvir-list mailing list