Skip to content

Redundant NULL check for pDir in ClrDataAccess::GetMetaDataFileInfoFromPEFile #125477

@SnowCoderX

Description

@SnowCoderX

Description

In daccess.cpp, the variable pDir is initialized to NULL and immediately checked with if (pDir == NULL || pDir->Size == 0). Since pDir is always NULL at this point, the condition is always true and the check is redundant.

Reproduction Steps

See ClrDataAccess::GetMetaDataFileInfoFromPEFile in daccess.cpp:
cppIMAGE_DATA_DIRECTORY *pDir = NULL;
// ...
if (pDir == NULL || pDir->Size == 0) // always true

Expected behavior

The condition should either be removed or restructured to reflect actual intent.

Actual behavior

The if condition is always true because pDir is always NULL at that point. Static analysis tools flag this as unreachable/redundant code

Regression?

N/A

Known Workarounds

None

Configuration

this is a code quality issue, not runtime-specific.

Other information

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions