[compiler-rt] [compiler-rt][profile] Fix InstrProfilingFile possible resource leak. (PR #81363)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 10 08:13:17 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-pgo
Author: David CARLIER (devnexen)
<details>
<summary>Changes</summary>
close #<!-- -->79708
---
Full diff: https://github.com/llvm/llvm-project/pull/81363.diff
1 Files Affected:
- (modified) compiler-rt/lib/profile/InstrProfilingFile.c (+3)
``````````diff
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);
}
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/81363
More information about the llvm-commits
mailing list