From nobody Tue Feb 10 15:01:18 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1611937020; cv=none; d=zohomail.com; s=zohoarc; b=Q8gfQokrG6WVBFUunrdTsWTzJ7YQCz6wFMm3q0hmY1blvMAhGHFrlXTB1mtoq9hh+edqeMqqHPxFIWUdCyuACOadwg3GPEW0ocKVMgF77yVCKfLOZ1B4t6aZg07SMVj6ggq4TfTP8jjK/OZH+iFFG20C3eFyB9fdgzbUSFd/QBg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611937020; h=Content-Type:Content-Transfer-Encoding:Cc: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=+iaG6y4SvHsKFIwzM2IKwOgN5Y9bc01Rw4YROjkZbo0=; b=gk22guhXSb3uUxHeUYrU+pta3ZMeUjX1VVMOmZGc8UD27tiUaleE9DGTTmPnw3ao/JiDePc6fK8Nn4CLL+oa8qtN2NsBjp7Hf53ed2iryOQAWAd/Qj1Nzl3ae8fLPkvmqria9gdBFO7pqfFYjjnR2mQST1y2fZqOeQ3E7BmK5JI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1611937020512856.3386905818835; Fri, 29 Jan 2021 08:17:00 -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-207-ZIgnxXGFMY-8U6snj6vy4g-1; Fri, 29 Jan 2021 11:16:56 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id E0BBB101AFC8; Fri, 29 Jan 2021 16:16:44 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BF5C11962F; Fri, 29 Jan 2021 16:16:44 +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 8939D50041; Fri, 29 Jan 2021 16:16:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 10TGGc6t010258 for ; Fri, 29 Jan 2021 11:16:38 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5C01E6E523; Fri, 29 Jan 2021 16:16:38 +0000 (UTC) Received: from work.redhat.com (ovpn-113-143.ams2.redhat.com [10.36.113.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9BAAC60871; Fri, 29 Jan 2021 16:16:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611937019; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=+iaG6y4SvHsKFIwzM2IKwOgN5Y9bc01Rw4YROjkZbo0=; b=N4Cyq0cwCSg6WH0eqiIELbhAk98Cry3w/BDJUpgoe17+uXAvlcG1sgm3LyNAlGxM0qIEsl mEUb6o3c3SQjAxZfDeJW5OaG2lmoHa0U47qbotgvitW4e01qoBghkNEJfBrQaPpei+cxSL 0+DZWGHcIn7NRBsCW7ak4d1aJp6iW1s= X-MC-Unique: ZIgnxXGFMY-8U6snj6vy4g-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 04/19] commandhelper: Consolidate error paths Date: Fri, 29 Jan 2021 17:16:14 +0100 Message-Id: <20210129161629.604823-5-twiederh@redhat.com> In-Reply-To: <20210129161629.604823-1-twiederh@redhat.com> References: <20210129161629.604823-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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.11 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" Preparation for later conversion to g_auto* memory handling. Signed-off-by: Tim Wiederhake --- tests/commandhelper.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/commandhelper.c b/tests/commandhelper.c index 05e3879688..2be121ce2c 100644 --- a/tests/commandhelper.c +++ b/tests/commandhelper.c @@ -61,7 +61,7 @@ int main(int argc, char **argv) { ssize_t got; =20 if (!log) - return ret; + goto cleanup; =20 for (i =3D 1; i < argc; i++) { fprintf(log, "ARG:%s\n", argv[i]); @@ -79,7 +79,7 @@ int main(int argc, char **argv) { } =20 if (!(newenv =3D malloc(sizeof(*newenv) * n))) - abort(); + goto cleanup; =20 for (i =3D 0; i < n; i++) { newenv[i] =3D environ[i]; @@ -222,8 +222,10 @@ int main(int argc, char **argv) { cleanup: for (i =3D 0; i < G_N_ELEMENTS(buffers); i++) free(buffers[i]); - fclose(log); - free(newenv); + if (newenv) + free(newenv); + if (log) + fclose(log); return ret; } =20 --=20 2.26.2