]> xenbits.xensource.com Git - libvirt.git/commitdiff
virTypedParamsSerialize: set remote_params_len at the end
authorMarc Hartmayer <mhartmay@linux.vnet.ibm.com>
Tue, 17 Jul 2018 12:02:32 +0000 (14:02 +0200)
committerJohn Ferlan <jferlan@redhat.com>
Mon, 23 Jul 2018 18:28:53 +0000 (14:28 -0400)
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>
Reviewed-by: John Ferlan <jferlan@redhat.com>
src/util/virtypedparam.c

index cfaa0dd9555d5e934039f2819ca484eaa6372519..c50d29eb55167b54ef7c5f932480120a9b1b1adb 100644 (file)
@@ -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;