Skip to content

Commit

Permalink
Fix memory leaks reported by static analyzer (#78492)
Browse files Browse the repository at this point in the history
  • Loading branch information
wscho77 authored Dec 13, 2022
1 parent e1300fe commit ea44671
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/coreclr/ilasm/assembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2737,4 +2737,9 @@ void Assembler::EmitGenericParamConstraints(int numTyPars, TyParDescr* pTyPars,
pGPC->Token(tkOwnerOfCA);
EmitCustomAttributes(tkOwnerOfCA, pGPC->CAList());
}

delete[] nConstraintsArr;
delete[] nConstraintIndexArr;
delete[] pConstraintsArr;
delete[] pGPConstraintsArr;
}
1 change: 1 addition & 0 deletions src/coreclr/pal/src/thread/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3651,6 +3651,7 @@ buildArgv(
(strcat_s(lpAsciiCmdLine, iLength, " ") != SAFECRT_SUCCESS))
{
ERROR("strcpy_s/strcat_s failed!\n");
free(lpAsciiCmdLine);
return NULL;
}

Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/tools/superpmi/mcs/verbconcat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,21 @@ int verbConcat::DoWork(const char* nameOfFile1, const char* nameOfFile2)
if (res == 0)
{
LogError("Failed to read '%s' from offset %lld. GetLastError()=%u", nameOfFile2, offset, GetLastError());
delete[] buffer;
return -1;
}
DWORD bytesWritten = -1;
BOOL res2 = WriteFile(hFileIn1, buffer, bytesRead, &bytesWritten, nullptr);
if (res2 == 0)
{
LogError("Failed to write '%s' at offset %lld. GetLastError()=%u", nameOfFile1, offset, GetLastError());
delete[] buffer;
return -1;
}
if (bytesRead != bytesWritten)
{
LogError("Failed to read/write matching bytes %u!=%u", bytesRead, bytesWritten);
delete[] buffer;
return -1;
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/coreclr/tools/superpmi/superpmi/parallelsuperpmi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,10 @@ static void MergeWorkerMCLs(char* mclFilename, PerWorkerData* workerData, int wo
// Write the merged MCL array back to disk
if (!WriteArrayToMCL(mclFilename, mergedMCL, totalCount))
LogError("Unable to write to MCL file %s.", mclFilename);

delete[] MCL;
delete[] MCLCount;
delete[] mergedMCL;
}

static void MergeWorkerCsvs(char* csvFilename, PerWorkerData* workerData, int workerCount, char* PerWorkerData::* csvPath)
Expand Down

0 comments on commit ea44671

Please sign in to comment.