From nobody Mon Feb 2 07:30:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1769611313; cv=none; d=zohomail.com; s=zohoarc; b=Bec8zoXeofzfgz84UBc3Nt+x58w96Y5YJKvbbUAQPNkCaqrVkTwqYQ2S4QgIMzBSxa51A78wSaDc+0ab3GUex8KgDZujUNJfHhmJjpQ4Pl/b2eg/k5TlUnIFbwYgXXKXDj177xnCP+WvRFWEomrLPw7lkA6I25qg+791+kVIUik= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769611313; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=iKcwoLWR60GkOBd9wOsRBWllUJpEf0MQrPAiBGdNtj0=; b=K+qGyeL16pto4+cTbuU2WYd0nobM3MgzGLo5TUOmInlPJCF+A/vu35uj27EzBJd6hVUn7nED4H70253xrvr4yYrjKs8yyGk2LLJNwdjB06ii7i/nwFVcx4MPUbuijtYeYG6hdxXWFXzH+XPDL/dixmDDzFVrWBVNARDW3yj8Xo8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1769611312995712.382073611387; Wed, 28 Jan 2026 06:41:52 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 1B751418E2; Wed, 28 Jan 2026 09:41:52 -0500 (EST) Received: from [172.19.199.3] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 6CDE343FC3; Wed, 28 Jan 2026 09:31:58 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id DBE99417DA; Wed, 28 Jan 2026 09:31:53 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id B3E2C41B10 for ; Wed, 28 Jan 2026 09:30:58 -0500 (EST) Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-424-Ilwvg93XNZiG9CykAjW66Q-1; Wed, 28 Jan 2026 09:30:56 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E593619775A5 for ; Wed, 28 Jan 2026 14:30:55 +0000 (UTC) Received: from moe (unknown [10.43.3.236]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4E250195419A for ; Wed, 28 Jan 2026 14:30:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769610658; h=from:from: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; bh=iKcwoLWR60GkOBd9wOsRBWllUJpEf0MQrPAiBGdNtj0=; b=P7EkpkQYpZ1lsXrknUzA7to5cef31p7SP7W0VZ7eU9qSwmwByfBPZCuCPcc+YNi8/4EZzU FNrXhcIw0mm77BIO1RxSF8RJe6U1wcYTaduemsC+xZoY+TcsiHSqHCAzN+AVVXoVk/aozl P0bBRRgTB9C8edd4sZyxpcI0mtOJQGc= X-MC-Unique: Ilwvg93XNZiG9CykAjW66Q-1 X-Mimecast-MFC-AGG-ID: Ilwvg93XNZiG9CykAjW66Q_1769610656 To: devel@lists.libvirt.org Subject: [PATCH 09/20] networkxml2conftest: Avoid potential leak Date: Wed, 28 Jan 2026 15:30:30 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: LKNUtVbCZHBtFQdvD2EoKyg4FV7QdESEW6k0jJs9gTM_1769610656 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: BUZC2JDPOHLOH23PMNJKDNDOOQ6IGRCR X-Message-ID-Hash: BUZC2JDPOHLOH23PMNJKDNDOOQ6IGRCR X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Michal Privoznik via Devel Reply-To: Michal Privoznik X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1769611313912158500 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik Inside of testCompareXMLToConfFiles() the network definition is parsed and if that succeeds a virNetworkObj is created by calling virNetworkObjNew(). But if the latter fails, the control jumps onto the fail label where only the object is freed but not already parsed definition leading to a leak. Swapping these two steps ensures that if either of them fails no memleak occurs. Signed-off-by: Michal Privoznik --- tests/networkxml2conftest.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/networkxml2conftest.c b/tests/networkxml2conftest.c index 67856f2e8c..d089ff38b1 100644 --- a/tests/networkxml2conftest.c +++ b/tests/networkxml2conftest.c @@ -33,17 +33,17 @@ testCompareXMLToConfFiles(const char *inxml, const char= *outconf, if (!(xmlopt =3D networkDnsmasqCreateXMLConf())) goto fail; =20 - if (!(def =3D virNetworkDefParse(NULL, inxml, xmlopt, false))) - goto fail; - - if (networkValidateTests(def) < 0) - goto fail; - if (!(obj =3D virNetworkObjNew())) goto fail; =20 + if (!(def =3D virNetworkDefParse(NULL, inxml, xmlopt, false))) + goto fail; + virNetworkObjSetDef(obj, def); =20 + if (networkValidateTests(def) < 0) + goto fail; + if (!networkNeedsDnsmasq(def)) { VIR_TEST_VERBOSE("spurious request to generate conf files. Would n= ot start dnsmasq in real life scenario"); goto fail; --=20 2.52.0