[compiler-rt] 0a255fc - [compiler-rt][profile] Fix InstrProfilingFile possible resource leak. (#81363)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 10 11:14:32 PST 2024
Author: David CARLIER
Date: 2024-02-10T19:14:28Z
New Revision: 0a255fcf4a90f9e864ae9321b28e4956f7c865fb
URL: https://github.com/llvm/llvm-project/commit/0a255fcf4a90f9e864ae9321b28e4956f7c865fb
DIFF: https://github.com/llvm/llvm-project/commit/0a255fcf4a90f9e864ae9321b28e4956f7c865fb.diff
LOG: [compiler-rt][profile] Fix InstrProfilingFile possible resource leak. (#81363)
close #79708
Added:
Modified:
compiler-rt/lib/profile/InstrProfilingFile.c
Removed:
################################################################################
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