[libvirt] [PATCH v2 0/2] Minor fixes for virTypedParams(De)Serialize

Changelog: + v1->v2: - Removed the the allocation change in virTypedParams(De)Serialize (John's comment) Marc Hartmayer (2): virTypedParamsSerialize: set remote_params_len at the end virTypedParamsDeserialize: set nparams to 0 in case of an error src/util/virtypedparam.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) -- 2.13.4

From: Marc Hartmayer <mhartmay@linux.vnet.ibm.com> Update the length @remote_params_len only if the related @remote_params_val has also been set. Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com> --- src/util/virtypedparam.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index 2452628cdbcd..c5fc68418c35 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -1501,8 +1501,8 @@ virTypedParamsSerialize(virTypedParameterPtr params, size_t j; int rv = -1; virTypedParameterRemotePtr params_val; + int params_len = nparams; - *remote_params_len = nparams; if (VIR_ALLOC_N(params_val, nparams) < 0) goto cleanup; @@ -1515,7 +1515,7 @@ virTypedParamsSerialize(virTypedParameterPtr params, if (!param->type || (!(flags & VIR_TYPED_PARAM_STRING_OKAY) && param->type == VIR_TYPED_PARAM_STRING)) { - --*remote_params_len; + --params_len; continue; } @@ -1556,6 +1556,7 @@ virTypedParamsSerialize(virTypedParameterPtr params, } *remote_params_val = params_val; + *remote_params_len = params_len; params_val = NULL; rv = 0; -- 2.13.4

From: Marc Hartmayer <mhartmay@linux.vnet.ibm.com> Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com> --- src/util/virtypedparam.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index c5fc68418c35..ef84642ee989 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -1467,6 +1467,7 @@ virTypedParamsDeserialize(virTypedParameterRemotePtr remote_params, } else { virTypedParamsFree(*params, i); *params = NULL; + *nparams = 0; } } return rv; -- 2.13.4

On 07/17/2018 08:02 AM, Marc Hartmayer wrote:
Changelog: + v1->v2: - Removed the the allocation change in virTypedParams(De)Serialize (John's comment)
Marc Hartmayer (2): virTypedParamsSerialize: set remote_params_len at the end virTypedParamsDeserialize: set nparams to 0 in case of an error
src/util/virtypedparam.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Reviewed-by: John Ferlan <jferlan@redhat.com> (series) John (and pushed)
participants (2)
-
John Ferlan
-
Marc Hartmayer