libxl: Don't free def member of virDomainObj

The refactoring in commit de49d5bad3 accidentally dropped the statement
setting def to NULL after successfully adding it to the virDomainObjList,
causing it to be freed while still in use. The resulting memory
corruption caused unpredictable behavior, often resulting in a libvirtd
crash.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
This commit is contained in:
Jim Fehlig 2020-09-24 10:39:13 -06:00
parent 88008f3b99
commit 709c0e7616

View File

@ -627,6 +627,7 @@ libxlAddDom0(libxlDriverPrivatePtr driver)
NULL)))
goto cleanup;
def = NULL;
vm->persistent = 1;
virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, VIR_DOMAIN_RUNNING_BOOTED);
}