Skip to content

Commit 0a255fc

Browse files
authored
[compiler-rt][profile] Fix InstrProfilingFile possible resource leak. (llvm#81363)
close llvm#79708
1 parent bc034ba commit 0a255fc

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

compiler-rt/lib/profile/InstrProfilingFile.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,7 @@ static void initializeProfileForContinuousMode(void) {
677677
PROF_ERR("Continuous counter sync mode is enabled, but raw profile is not"
678678
"page-aligned. CurrentFileOffset = %" PRIu64 ", pagesz = %u.\n",
679679
(uint64_t)CurrentFileOffset, PageSize);
680+
fclose(File);
680681
return;
681682
}
682683
if (writeProfileWithFileObject(Filename, File) != 0) {
@@ -692,6 +693,8 @@ static void initializeProfileForContinuousMode(void) {
692693

693694
if (doMerging()) {
694695
lprofUnlockFileHandle(File);
696+
}
697+
if (File != NULL) {
695698
fclose(File);
696699
}
697700
}

0 commit comments

Comments
 (0)