From nobody Thu May 15 07:00:51 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1512974242826986.0440664914304; Sun, 10 Dec 2017 22:37:22 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 502CDC058EDD; Mon, 11 Dec 2017 06:37:21 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2F1A9600D5; Mon, 11 Dec 2017 06:37:21 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E991F1800FC5; Mon, 11 Dec 2017 06:37:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vBB6ZF85012873 for ; Mon, 11 Dec 2017 01:35:15 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1327D17C70; Mon, 11 Dec 2017 06:35:15 +0000 (UTC) Received: from localhost.localdomain (ovpn-204-41.brq.redhat.com [10.40.204.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4A0C32A308; Mon, 11 Dec 2017 06:35:14 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Mon, 11 Dec 2017 07:34:59 +0100 Message-Id: <5685b3fe32a787455a78e5d8d5f9a75ac467d33b.1512974038.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: eskultet@redhat.com Subject: [libvirt] [libvirt-php][PATCH 5/5] src: Don't leak connection_get_emulator retval X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 11 Dec 2017 06:37:21 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Michal Privoznik Reviewed-by: Erik Skultety --- src/libvirt-connection.c | 2 ++ src/libvirt-php.c | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/libvirt-connection.c b/src/libvirt-connection.c index 086cd57..9e70031 100644 --- a/src/libvirt-connection.c +++ b/src/libvirt-connection.c @@ -404,6 +404,7 @@ PHP_FUNCTION(libvirt_connect_get_nic_models) char cmd[4096] =3D { 0 }; char tmp2[16] =3D { 0 }; snprintf(cmd, sizeof(cmd), "%s -net nic,model=3D? 2>&1", tmp); + VIR_FREE(tmp); =20 FILE *fp =3D popen(cmd, "r"); if (fp =3D=3D NULL) @@ -475,6 +476,7 @@ PHP_FUNCTION(libvirt_connect_get_soundhw_models) =20 char cmd[4096] =3D { 0 }; snprintf(cmd, sizeof(cmd), "%s -soundhw help 2>&1", tmp); + VIR_FREE(tmp); =20 FILE *fp =3D popen(cmd, "r"); if (fp =3D=3D NULL) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index 5ec6e60..cf8fd7f 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -2277,6 +2277,7 @@ char *installation_get_xml(virConnectPtr conn, char *= name, int memMB, { int i; char *xml =3D NULL; + char *emulator =3D NULL; char disks_xml[16384] =3D { 0 }; char networks_xml[16384] =3D { 0 }; char features[128] =3D { 0 }; @@ -2304,6 +2305,11 @@ char *installation_get_xml(virConnectPtr conn, char = *name, int memMB, DPRINTF("%s: No architecture defined, got host arch of '%s'\n", __= FUNCTION__, arch); } =20 + if (!(emulator =3D connection_get_emulator(conn, arch TSRMLS_CC))) { + DPRINTF("%s: Cannot get emulator\n", __FUNCTION__); + return NULL; + } + if (iso_image && access(iso_image, R_OK) !=3D 0) { DPRINTF("%s: Installation image %s doesn't exist\n", __FUNCTION__,= iso_image); return NULL; @@ -2370,7 +2376,7 @@ char *installation_get_xml(virConnectPtr conn, char *= name, int memMB, "", type, name, memMB * 1024, maxmemMB * 1024, uuid, arch, feature= s, (domain_flags & DOMAIN_FLAG_CLOCK_LOCALTIME ? "localtime" : "u= tc"), - vCpus, connection_get_emulator(conn, arch TSRMLS_CC), disks_xm= l, + vCpus, emulator, disks_xml, iso_image, networks_xml, (domain_flags & DOMAIN_FLAG_SOUND_AC97 ? "\n" : "")); } else { @@ -2409,11 +2415,12 @@ char *installation_get_xml(virConnectPtr conn, char= *name, int memMB, "", type, name, memMB * 1024, maxmemMB * 1024, uuid, arch, feature= s, (domain_flags & DOMAIN_FLAG_CLOCK_LOCALTIME ? "localtime" : "u= tc"), - vCpus, connection_get_emulator(conn, arch TSRMLS_CC), disks_xm= l, + vCpus, emulator, disks_xml, networks_xml, (domain_flags & DOMAIN_FLAG_SOUND_AC97 ? "\n" : "")); } =20 + VIR_FREE(emulator); VIR_FREE(tmp); VIR_FREE(arch); if (rv < 0) --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list