]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
rpc: first allocate the memory and then set the count
authorMarc Hartmayer <mhartmay@linux.vnet.ibm.com>
Wed, 7 Jun 2017 08:46:39 +0000 (10:46 +0200)
committerJohn Ferlan <jferlan@redhat.com>
Mon, 12 Jun 2017 23:11:30 +0000 (19:11 -0400)
Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
src/rpc/virnetclientprogram.c

index e620dec98bfe4b02c91bd094e4919b0809d3fa10..c9d57ec6bc0f2beefde42d821d8758bc3ba0cdc4 100644 (file)
@@ -296,9 +296,9 @@ int virNetClientProgramCall(virNetClientProgramPtr prog,
     msg->header.type = noutfds ? VIR_NET_CALL_WITH_FDS : VIR_NET_CALL;
     msg->header.serial = serial;
     msg->header.proc = proc;
-    msg->nfds = noutfds;
-    if (VIR_ALLOC_N(msg->fds, msg->nfds) < 0)
+    if (VIR_ALLOC_N(msg->fds, noutfds) < 0)
         goto error;
+    msg->nfds = noutfds;
     for (i = 0; i < msg->nfds; i++)
         msg->fds[i] = -1;
     for (i = 0; i < msg->nfds; i++) {