[compiler-rt][profile] Fix InstrProfilingFile possible resource leak. (#81363)

close #79708

(cherry picked from commit 0a255fcf4a90f9e864ae9321b28e4956f7c865fb)
This commit is contained in:
David CARLIER 2024-02-10 19:14:28 +00:00 committed by Tom Stellard
parent 3b4b047642
commit 390dcd4cbb

View File

@ -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);
}
}