]> git.ipfire.org Git - thirdparty/libvirt.git/commit
virConnectOpenInternal: Avoid double free() when alias is an invalid URI
authorPeter Krempa <pkrempa@redhat.com>
Thu, 8 Sep 2022 14:31:58 +0000 (16:31 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 13 Sep 2022 08:50:02 +0000 (10:50 +0200)
commit48e1b49353a5700427288185ca12c301ef2cfa3a
tree5bc737b9cfa804d4292122e9e5d5a3eda0583408
parentd3397885d589c25b8962ae221fd0a71ced5597cb
virConnectOpenInternal: Avoid double free() when alias is an invalid URI

Configuring an URI alias such as

  uri_aliases = [
      "blah=qemu://invaliduri@@@",
  ]

Results in a double free when the alias is used:

  $ virsh -c blah
  free(): double free detected in tcache 2
  Aborted (core dumped)

This happens as the 'alias' variable is first assigned to 'uristr' which
is cleared in the 'failed' label and then is explicitly freed again.

Fix this by stealing the alias into 'uristr' and removing the
unnecessary freeing.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/libvirt.c