From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web09.9783.1648123484037938204 for ; Thu, 24 Mar 2022 05:04:44 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bA3metdp; spf=pass (domain: redhat.com, ip: 170.10.133.124, mailfrom: kraxel@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648123483; h=from:from: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; bh=CjvJ2329EcIzYK1KibMr82ZfnvbOC7tWRctXurGmWzs=; b=bA3metdp+NQ+SduLDySlWDkb+l1tLcAakyjiltVbVsjPFnA0n8AHxrgohNrO8h7MFupBi/ xYmooU1YtVmmq49jrxk9A0GuQJ8rSg8K0xzlh1sDvqXwnMc2iM9GQEMSHoLrDYoblv3IK7 7bj7oP8yR79DPZzWT+m9NvzlZqwgo0w= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-564-rat00wuJOtGIdLEekxgWMw-1; Thu, 24 Mar 2022 08:04:39 -0400 X-MC-Unique: rat00wuJOtGIdLEekxgWMw-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 748F43C163E1; Thu, 24 Mar 2022 12:04:39 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.196.67]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3606C698CF0; Thu, 24 Mar 2022 12:04:39 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 511121800614; Thu, 24 Mar 2022 13:04:36 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Pawel Polawski , Liming Gao , Yuwei Chen , Oliver Steffen , Bob Feng , Gerd Hoffmann Subject: [PATCH 1/3] BaseTools: fix gcc12 warning Date: Thu, 24 Mar 2022 13:04:34 +0100 Message-Id: <20220324120436.939688-2-kraxel@redhat.com> In-Reply-To: <20220324120436.939688-1-kraxel@redhat.com> References: <20220324120436.939688-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GenFfs.c:545:5: error: pointer ‘InFileHandle’ used after ‘fclose’ [-Werror=use-after-free] 545 | Error(NULL, 0, 4001, "Resource", "memory cannot be allocated of %s", InFileHandle); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GenFfs.c:544:5: note: call to ‘fclose’ here 544 | fclose (InFileHandle); | ^~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Gerd Hoffmann --- BaseTools/Source/C/GenFfs/GenFfs.c | 2 +- BaseTools/Source/C/GenSec/GenSec.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/BaseTools/Source/C/GenFfs/GenFfs.c b/BaseTools/Source/C/GenFfs/GenFfs.c index 949025c33325..d78d62ab3689 100644 --- a/BaseTools/Source/C/GenFfs/GenFfs.c +++ b/BaseTools/Source/C/GenFfs/GenFfs.c @@ -542,7 +542,7 @@ GetAlignmentFromFile(char *InFile, UINT32 *Alignment) PeFileBuffer = (UINT8 *) malloc (PeFileSize); if (PeFileBuffer == NULL) { fclose (InFileHandle); - Error(NULL, 0, 4001, "Resource", "memory cannot be allocated of %s", InFileHandle); + Error(NULL, 0, 4001, "Resource", "memory cannot be allocated for %s", InFile); return EFI_OUT_OF_RESOURCES; } fread (PeFileBuffer, sizeof (UINT8), PeFileSize, InFileHandle); diff --git a/BaseTools/Source/C/GenSec/GenSec.c b/BaseTools/Source/C/GenSec/GenSec.c index d54a4f9e0a7d..b1d05367ec0b 100644 --- a/BaseTools/Source/C/GenSec/GenSec.c +++ b/BaseTools/Source/C/GenSec/GenSec.c @@ -1062,7 +1062,7 @@ GetAlignmentFromFile(char *InFile, UINT32 *Alignment) PeFileBuffer = (UINT8 *) malloc (PeFileSize); if (PeFileBuffer == NULL) { fclose (InFileHandle); - Error(NULL, 0, 4001, "Resource", "memory cannot be allocated of %s", InFileHandle); + Error(NULL, 0, 4001, "Resource", "memory cannot be allocated for %s", InFile); return EFI_OUT_OF_RESOURCES; } fread (PeFileBuffer, sizeof (UINT8), PeFileSize, InFileHandle); -- 2.35.1