]> git.ipfire.org Git - thirdparty/libvirt.git/commit
virnetsocket: Don't free virCommand in virNetSocketNewConnectCommand()
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 15 Oct 2021 11:39:36 +0000 (13:39 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 15 Oct 2021 14:03:22 +0000 (16:03 +0200)
commit44d8324f13006cdd4cca0d0fc4c52b7ca80b2455
tree77aa75f96cceffb9d385ae2ea731f7dbb32ba922
parentd9afe162abf1ff71dd8843cae3ce308cebbd1574
virnetsocket: Don't free virCommand in virNetSocketNewConnectCommand()

The aim of virNetSocketNewConnectCommand() is to execute passed
command and attach socket pair/pipe to it so that client socket
can be opened (this is used for connections with alternative
transports, e.g. ssh). The virCommand is created in a caller and
then passed to virNetSocketNewConnectCommand() where it is freed
using virCommandFree(). This approach is wrong on two levels:

1) The deallocation happens on a different level than allocation,
2) There's a WIN32 stub that just reports an error and doesn't
   free the command.

However, with g_autoptr() trickery the command can be freed in
caller.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/rpc/virnetsocket.c
tests/virnetsockettest.c