From nobody Sun Feb 8 19:02:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606913054; cv=none; d=zohomail.com; s=zohoarc; b=nDNQjTSSFZZ6kdbB53apNFJIUt4eSISFK6RCyzWNsOVk3/1CVC59EtUrblL7FMQKe7w5/K6mVPSfEkl8D+pYiSPOdufPmpAIy2l8ktXsGyK4WeSU+fILw6/SgADYBEnNktFk/MCvIrbJAUVcaobWtgxmo3wrcSIqn9YdT3nGcHw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606913054; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/sXtZYSbWgKrdinusGqUO88U+wpkrIIqbiknDMIWT6w=; b=WPBpeJAArT3GxTpsRMTzr7S7u1QbPF0j2WTtAFAWPKVsU8+hoMhSBnVwksEOH9rClwrVF/SHCGDvNyz7IH/7sg2OhyLk8lKy0al1MpmqXapITTPXCDiVpxNG7fhx4l/PSOKO/WyrR5Kp8QvrHHGLxG048Qaw0NSAmG4XPuk+ngU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1606913054493667.4804041404734; Wed, 2 Dec 2020 04:44:14 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-288-zfxHy9WrP8y1ieQgYnjs9g-1; Wed, 02 Dec 2020 07:44:11 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0987D107B463; Wed, 2 Dec 2020 12:44:06 +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 DA14E60C0F; Wed, 2 Dec 2020 12:44:05 +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 A0C971809CA7; Wed, 2 Dec 2020 12:44:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0B2ChSrS003695 for ; Wed, 2 Dec 2020 07:43:28 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2582360C0F; Wed, 2 Dec 2020 12:43:28 +0000 (UTC) Received: from fedora.redhat.com (ovpn-112-197.phx2.redhat.com [10.3.112.197]) by smtp.corp.redhat.com (Postfix) with ESMTP id DC9A060BFA for ; Wed, 2 Dec 2020 12:43:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606913053; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=/sXtZYSbWgKrdinusGqUO88U+wpkrIIqbiknDMIWT6w=; b=JDBPEUzkMDMMq+1Z2xcuVXsKcEyig2iunZZ89BxLWxLRGtgp1pO7CAk3/srVU9jU6nEy9h wRtUXkRYE7GbfsB5b69pq2vT/aGuQ9dXGBLHUklQZZ36Slawu4K8biJKtZjNF9On0htT7f AP5iaKMh/l2K53uqTA4EZ0UXQhoWbio= X-MC-Unique: zfxHy9WrP8y1ieQgYnjs9g-1 From: John Ferlan To: libvir-list@redhat.com Subject: [PATCH 5/7] logging: Resolve mem leak in virLogDaemonPreExecRestart Date: Wed, 2 Dec 2020 07:43:19 -0500 Message-Id: <20201202124321.765271-6-jferlan@redhat.com> In-Reply-To: <20201202124321.765271-1-jferlan@redhat.com> References: <20201202124321.765271-1-jferlan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Initialize and free @magic since virJSONValueObjectAppendString does not free it for us eventually. Signed-off-by: John Ferlan Reviewed-by: J=C3=A1n Tomko --- src/logging/log_daemon.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/logging/log_daemon.c b/src/logging/log_daemon.c index be93c63eb5..6b8f3b6fe5 100644 --- a/src/logging/log_daemon.c +++ b/src/logging/log_daemon.c @@ -508,7 +508,7 @@ virLogDaemonPreExecRestart(const char *state_file, virJSONValuePtr child; char *state =3D NULL; virJSONValuePtr object =3D virJSONValueNewObject(); - char *magic; + char *magic =3D NULL; =20 VIR_DEBUG("Running pre-restart exec"); =20 @@ -523,10 +523,8 @@ virLogDaemonPreExecRestart(const char *state_file, if (!(magic =3D virLogDaemonGetExecRestartMagic())) goto cleanup; =20 - if (virJSONValueObjectAppendString(object, "magic", magic) < 0) { - VIR_FREE(magic); + if (virJSONValueObjectAppendString(object, "magic", magic) < 0) goto cleanup; - } =20 if (!(child =3D virLogHandlerPreExecRestart(logDaemon->handler))) goto cleanup; @@ -559,6 +557,7 @@ virLogDaemonPreExecRestart(const char *state_file, abort(); /* This should be impossible to reach */ =20 cleanup: + VIR_FREE(magic); VIR_FREE(state); virJSONValueFree(object); return -1; --=20 2.28.0