Blame 0030-BaseTools-fix-gcc12-warning.patch

Gerd Hoffmann e3d786
From 84d64059dd0082609a43c7938a8a35e10da10706 Mon Sep 17 00:00:00 2001
Gerd Hoffmann e3d786
From: Gerd Hoffmann <kraxel@redhat.com>
Gerd Hoffmann e3d786
Date: Mon, 24 Jan 2022 11:03:25 +0100
Gerd Hoffmann e3d786
Subject: [PATCH 30/32] BaseTools: fix gcc12 warning
Gerd Hoffmann e3d786
MIME-Version: 1.0
Gerd Hoffmann e3d786
Content-Type: text/plain; charset=UTF-8
Gerd Hoffmann e3d786
Content-Transfer-Encoding: 8bit
Gerd Hoffmann e3d786
Gerd Hoffmann e3d786
GenFfs.c:545:5: error: pointer ‘InFileHandle’ used after ‘fclose’ [-Werror=use-after-free]
Gerd Hoffmann e3d786
  545 |     Error(NULL, 0, 4001, "Resource", "memory cannot be allocated  of %s", InFileHandle);
Gerd Hoffmann e3d786
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Gerd Hoffmann e3d786
GenFfs.c:544:5: note: call to ‘fclose’ here
Gerd Hoffmann e3d786
  544 |     fclose (InFileHandle);
Gerd Hoffmann e3d786
      |     ^~~~~~~~~~~~~~~~~~~~~
Gerd Hoffmann e3d786
Gerd Hoffmann e3d786
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Gerd Hoffmann e3d786
---
Gerd Hoffmann e3d786
 BaseTools/Source/C/GenFfs/GenFfs.c | 2 +-
Gerd Hoffmann e3d786
 BaseTools/Source/C/GenSec/GenSec.c | 2 +-
Gerd Hoffmann e3d786
 2 files changed, 2 insertions(+), 2 deletions(-)
Gerd Hoffmann e3d786
Gerd Hoffmann e3d786
diff --git a/BaseTools/Source/C/GenFfs/GenFfs.c b/BaseTools/Source/C/GenFfs/GenFfs.c
Gerd Hoffmann e3d786
index 949025c33325..d78d62ab3689 100644
Gerd Hoffmann e3d786
--- a/BaseTools/Source/C/GenFfs/GenFfs.c
Gerd Hoffmann e3d786
+++ b/BaseTools/Source/C/GenFfs/GenFfs.c
Gerd Hoffmann e3d786
@@ -542,7 +542,7 @@ GetAlignmentFromFile(char *InFile, UINT32 *Alignment)
Gerd Hoffmann e3d786
   PeFileBuffer = (UINT8 *) malloc (PeFileSize);
Gerd Hoffmann e3d786
   if (PeFileBuffer == NULL) {
Gerd Hoffmann e3d786
     fclose (InFileHandle);
Gerd Hoffmann e3d786
-    Error(NULL, 0, 4001, "Resource", "memory cannot be allocated  of %s", InFileHandle);
Gerd Hoffmann e3d786
+    Error(NULL, 0, 4001, "Resource", "memory cannot be allocated for %s", InFile);
Gerd Hoffmann e3d786
     return EFI_OUT_OF_RESOURCES;
Gerd Hoffmann e3d786
   }
Gerd Hoffmann e3d786
   fread (PeFileBuffer, sizeof (UINT8), PeFileSize, InFileHandle);
Gerd Hoffmann e3d786
diff --git a/BaseTools/Source/C/GenSec/GenSec.c b/BaseTools/Source/C/GenSec/GenSec.c
Gerd Hoffmann e3d786
index d54a4f9e0a7d..b1d05367ec0b 100644
Gerd Hoffmann e3d786
--- a/BaseTools/Source/C/GenSec/GenSec.c
Gerd Hoffmann e3d786
+++ b/BaseTools/Source/C/GenSec/GenSec.c
Gerd Hoffmann e3d786
@@ -1062,7 +1062,7 @@ GetAlignmentFromFile(char *InFile, UINT32 *Alignment)
Gerd Hoffmann e3d786
   PeFileBuffer = (UINT8 *) malloc (PeFileSize);
Gerd Hoffmann e3d786
   if (PeFileBuffer == NULL) {
Gerd Hoffmann e3d786
     fclose (InFileHandle);
Gerd Hoffmann e3d786
-    Error(NULL, 0, 4001, "Resource", "memory cannot be allocated  of %s", InFileHandle);
Gerd Hoffmann e3d786
+    Error(NULL, 0, 4001, "Resource", "memory cannot be allocated for %s", InFile);
Gerd Hoffmann e3d786
     return EFI_OUT_OF_RESOURCES;
Gerd Hoffmann e3d786
   }
Gerd Hoffmann e3d786
   fread (PeFileBuffer, sizeof (UINT8), PeFileSize, InFileHandle);
Gerd Hoffmann e3d786
-- 
Gerd Hoffmann e3d786
2.35.1
Gerd Hoffmann e3d786