From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60237) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vu8Rg-00082I-D3 for qemu-devel@nongnu.org; Fri, 20 Dec 2013 17:21:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vu8Re-0005cv-KJ for qemu-devel@nongnu.org; Fri, 20 Dec 2013 17:21:24 -0500 Received: from mail-ea0-x235.google.com ([2a00:1450:4013:c01::235]:35320) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vu8Re-0005cg-E9 for qemu-devel@nongnu.org; Fri, 20 Dec 2013 17:21:22 -0500 Received: by mail-ea0-f181.google.com with SMTP id m10so1329867eaj.12 for ; Fri, 20 Dec 2013 14:21:21 -0800 (PST) Sender: Paolo Bonzini From: Paolo Bonzini Date: Fri, 20 Dec 2013 23:21:07 +0100 Message-Id: <1387578070-2884-3-git-send-email-pbonzini@redhat.com> In-Reply-To: <1387578070-2884-1-git-send-email-pbonzini@redhat.com> References: <1387578070-2884-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH v3 2/5] qom: fix leak for objects created with -object List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: imammedo@redhat.com, afaerber@suse.de, lcapitulino@xilinx.com The object must be unref-ed when its variable goes out of scope. Signed-off-by: Paolo Bonzini --- vl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vl.c b/vl.c index 7511e70..45f9177 100644 --- a/vl.c +++ b/vl.c @@ -2809,12 +2809,13 @@ static int object_create(QemuOpts *opts, void *opaque) obj = object_new(type); if (qemu_opt_foreach(opts, object_set_property, obj, 1) < 0) { + object_unref(obj); return -1; } object_property_add_child(container_get(object_get_root(), "/objects"), id, obj, NULL); - + object_unref(obj); return 0; } -- 1.8.4.2