]> git.ipfire.org Git - thirdparty/libvirt.git/commit
qemu: Fix segfault when parsing private domain data
authorMartin Kletzander <mkletzan@redhat.com>
Thu, 13 Aug 2015 08:03:12 +0000 (10:03 +0200)
committerCole Robinson <crobinso@redhat.com>
Tue, 22 Sep 2015 00:17:59 +0000 (20:17 -0400)
commitedf314d71004c351460d49d712433e4b3b41eebd
tree6b1e22ecc937467393684d681816089daf7ed50b
parent79be4dbecb9a6dc77b51fdb0a966c9eac835318a
qemu: Fix segfault when parsing private domain data

When parsing private domain data, there are two paths that are flawed.
They are both error paths, just from different parts of the function.
One of them can call free() on an uninitialized pointer.  Initialization
to NULL is enough here.  The other one is a bit trickier to explain, but
as easy as the first one to fix.  We create capabilities, parse them and
then assign them into the private data pointer inside the domain object.
If, however, we get to fail from now on, the error path calls unrefs the
capabilities and then, when the domain object is being cleaned,
qemuDomainObjPrivateFree() tries to unref them as well.  That causes a
segfault.  Settin the pointer to NULL upon successful addition to the
private data is enough.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
(cherry picked from commit 92ddffdbd3c91d99f8f7ed9b661388a2c5d36cc2)
src/qemu/qemu_domain.c