From: Marc Hartmayer Date: Wed, 7 Jun 2017 08:46:39 +0000 (+0200) Subject: rpc: first allocate the memory and then set the count X-Git-Tag: v3.5.0-rc1~102 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e9538813ec8f56b7c73a99c40c3fe8247a75e02a;p=thirdparty%2Flibvirt.git rpc: first allocate the memory and then set the count Signed-off-by: Marc Hartmayer Reviewed-by: Boris Fiuczynski Reviewed-by: Bjoern Walk --- diff --git a/src/rpc/virnetclientprogram.c b/src/rpc/virnetclientprogram.c index e620dec98b..c9d57ec6bc 100644 --- a/src/rpc/virnetclientprogram.c +++ b/src/rpc/virnetclientprogram.c @@ -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++) {