From ada1c136629f47ade4c0996b518de5570e225427 Mon Sep 17 00:00:00 2001 From: danghvu Date: Wed, 6 Jul 2016 01:49:10 -0500 Subject: [PATCH] Fix memleak: do not re-initialize halt_cond --- qemu/cpus.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/qemu/cpus.c b/qemu/cpus.c index 79f2eeb7..0dc3346f 100644 --- a/qemu/cpus.c +++ b/qemu/cpus.c @@ -140,8 +140,10 @@ static int qemu_tcg_init_vcpu(CPUState *cpu) tcg_cpu_address_space_init(cpu, cpu->as); /* share a single thread for all cpus with TCG */ - cpu->halt_cond = g_malloc0(sizeof(QemuCond)); - qemu_cond_init(cpu->halt_cond); + if (!cpu->halt_cond) { + cpu->halt_cond = g_malloc0(sizeof(QemuCond)); + qemu_cond_init(cpu->halt_cond); + } uc->tcg_halt_cond = cpu->halt_cond; return 0;