[compiler-rt] [compiler-rt][profile] Fix InstrProfilingFile possible resource leak. (PR #81363)
David CARLIER via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 10 08:12:47 PST 2024
https://github.com/devnexen created https://github.com/llvm/llvm-project/pull/81363
close #79708
>From adbc55e3a06494d2c9f42e573ff92d5e6d61fbee Mon Sep 17 00:00:00 2001
From: David Carlier <devnexen at gmail.com>
Date: Sat, 10 Feb 2024 16:11:15 +0000
Subject: [PATCH] [compiler-rt][profile] Fix InstrProfilingFile possible
resource leak.
close #79708
---
compiler-rt/lib/profile/InstrProfilingFile.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/compiler-rt/lib/profile/InstrProfilingFile.c b/compiler-rt/lib/profile/InstrProfilingFile.c
index 867ae73f0d3b27..f3b457d786e6bd 100644
--- a/compiler-rt/lib/profile/InstrProfilingFile.c
+++ b/compiler-rt/lib/profile/InstrProfilingFile.c
@@ -677,6 +677,7 @@ static void initializeProfileForContinuousMode(void) {
PROF_ERR("Continuous counter sync mode is enabled, but raw profile is not"
"page-aligned. CurrentFileOffset = %" PRIu64 ", pagesz = %u.\n",
(uint64_t)CurrentFileOffset, PageSize);
+ fclose(File);
return;
}
if (writeProfileWithFileObject(Filename, File) != 0) {
@@ -692,6 +693,8 @@ static void initializeProfileForContinuousMode(void) {
if (doMerging()) {
lprofUnlockFileHandle(File);
+ }
+ if (File != NULL) {
fclose(File);
}
}
More information about the llvm-commits
mailing list