Skip to content

Commit 43f2d94

Browse files
kaybelevjkotas
andauthored
runtime: minor bugs fixed in coreclr and libraries (#97155)
* Fixed error: <Pointer, returned from function 'gmtime_r' at filetime.cpp:262, may be NULL and is dereferenced at filetime.cpp:268>. The error was detected using the Svace analyzer maded by ISP RAS. * Fixed error: <Return value of a function 'PAL_wcsrchr' is dereferenced at process.cpp:2824 without checking for NULL, but it is usually checked for this function (11/12)>. The error was detected using the Svace analyzer maded by ISP RAS. * Fixed error: <Value sectionRecord, which is result of method invocation with possible null return value, is dereferenced in member access expression sectionRecord.HasLocationInput>. The error was detected using the Svace analyzer maded by ISP RAS. * Fixed error: <Maybe ecmaCandidateMethod, that created from method with AS-cast should be compared with null instead of method>. The error was detected using the Svace analyzer maded by ISP RAS. * Update filetime.cpp * Update process.cpp * Update MgmtConfigurationRecord.cs * Update src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/MgmtConfigurationRecord.cs Co-authored-by: Jan Kotas <jkotas@microsoft.com> * Update src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/MgmtConfigurationRecord.cs Co-authored-by: Jan Kotas <jkotas@microsoft.com> --------- Co-authored-by: Jan Kotas <jkotas@microsoft.com>
1 parent 3d4a82b commit 43f2d94

4 files changed

Lines changed: 15 additions & 2 deletions

File tree

src/coreclr/pal/src/file/filetime.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,13 @@ BOOL PALAPI FileTimeToSystemTime( CONST FILETIME * lpFileTime,
263263
#else /* HAVE_GMTIME_R */
264264
UnixSystemTime = gmtime( &UnixFileTime );
265265
#endif /* HAVE_GMTIME_R */
266-
266+
if (!UnixSystemTime)
267+
{
268+
ERROR( "gmtime failed.\n" );
269+
SetLastError(ERROR_INVALID_PARAMETER);
270+
return FALSE;
271+
}
272+
267273
/* Convert unix system time to Windows system time. */
268274
lpSystemTime->wDay = (WORD)UnixSystemTime->tm_mday;
269275

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2821,6 +2821,12 @@ CorUnix::InitializeProcessCommandLine(
28212821
if (lpwstrFullPath)
28222822
{
28232823
LPWSTR lpwstr = PAL_wcsrchr(lpwstrFullPath, '/');
2824+
if (!lpwstr)
2825+
{
2826+
ERROR("Invalid full path\n");
2827+
palError = ERROR_INTERNAL_ERROR;
2828+
goto exit;
2829+
}
28242830
lpwstr[0] = '\0';
28252831
size_t n = PAL_wcslen(lpwstrFullPath) + 1;
28262832

src/coreclr/tools/aot/ILCompiler.ReadyToRun/IBC/IBCProfileParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ private uint LookupIbcMethodToken(MetadataType methodMetadataType, uint ibcToken
414414
if (method.Name == methodName)
415415
{
416416
EcmaMethod ecmaCandidateMethod = method as EcmaMethod;
417-
if (method == null)
417+
if (ecmaCandidateMethod == null)
418418
continue;
419419

420420
MetadataReader metadataReader = ecmaCandidateMethod.MetadataReader;

src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/MgmtConfigurationRecord.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ internal ConfigurationSection FindImmediateParentSection(ConfigurationSection se
335335

336336
string configKey = section.SectionInformation.SectionName;
337337
SectionRecord sectionRecord = GetSectionRecord(configKey, false);
338+
Debug.Assert(sectionRecord != null);
338339
if (sectionRecord.HasLocationInputs)
339340
{
340341
SectionInput input = sectionRecord.LastLocationInput;

0 commit comments

Comments
 (0)