1. Don't allocate if there is nothing that needs to be allocated. Especially as the result of calling calloc(0, ...) is implementation-defined. 2. Reset @nparams to 0 in case of an error. Signed-off-by: Marc Hartmayer <mhartmay@xxxxxxxxxxxxxxxxxx> Reviewed-by: Boris Fiuczynski <fiuczy@xxxxxxxxxxxxx> --- src/util/virtypedparam.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index 10fd28baa65c..01716b517ad2 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -1402,7 +1402,7 @@ virTypedParamsDeserialize(virTypedParameterRemotePtr remote_params, goto cleanup; } } else { - if (VIR_ALLOC_N(*params, remote_params_len) < 0) + if (remote_params_len && VIR_ALLOC_N(*params, remote_params_len) < 0) goto cleanup; } *nparams = remote_params_len; @@ -1467,6 +1467,7 @@ virTypedParamsDeserialize(virTypedParameterRemotePtr remote_params, } else { virTypedParamsFree(*params, i); *params = NULL; + *nparams = 0; } } return rv; -- 2.13.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list