Skip to content

Commit e574380

Browse files
HJLeeestephentoub
andauthored
Free getline buffer after use (#74899)
* Free getline buffer after use * Apply Feedback Co-authored-by: Stephen Toub <[email protected]> Co-authored-by: Stephen Toub <[email protected]>
1 parent 2d99ed7 commit e574380

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/coreclr/pal/src/thread/process.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1675,6 +1675,8 @@ GetProcessIdDisambiguationKey(DWORD processId, UINT64 *disambiguationKey)
16751675
{
16761676
TRACE("GetProcessIdDisambiguationKey: getline() FAILED");
16771677
SetLastError(ERROR_INVALID_HANDLE);
1678+
free(line);
1679+
fclose(statFile);
16781680
return FALSE;
16791681
}
16801682

@@ -1691,15 +1693,15 @@ GetProcessIdDisambiguationKey(DWORD processId, UINT64 *disambiguationKey)
16911693
"%*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u %*u %*u %*d %*d %*d %*d %*d %*d %llu \n",
16921694
&starttime);
16931695

1696+
free(line);
1697+
fclose(statFile);
1698+
16941699
if (sscanfRet != 1)
16951700
{
16961701
_ASSERTE(!"Failed to parse stat file contents with sscanf_s.");
16971702
return FALSE;
16981703
}
16991704

1700-
free(line);
1701-
fclose(statFile);
1702-
17031705
*disambiguationKey = starttime;
17041706
return TRUE;
17051707

src/native/corehost/hostmisc/pal.unix.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ namespace
171171
}
172172

173173
fclose(file);
174+
free(line);
174175
if (!found)
175176
return false;
176177

0 commit comments

Comments
 (0)