Skip to content

Remove dead code in R2RPEBuilder#115953

Merged
elinor-fung merged 1 commit intodotnet:mainfrom
elinor-fung:r2rpebuilder-deadCode
May 28, 2025
Merged

Remove dead code in R2RPEBuilder#115953
elinor-fung merged 1 commit intodotnet:mainfrom
elinor-fung:r2rpebuilder-deadCode

Conversation

@elinor-fung
Copy link
Member

No description provided.

Copilot AI review requested due to automatic review settings May 23, 2025 23:26
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR removes unused code from R2RPEBuilder to simplify section relocation logic.

  • Deletes the SectionRVADelta struct and its list field
  • Removes RelocateRVA and RelocateDirectoryEntry methods
  • Drops the SDataSectionName constant and related dead comments

_sectionBuilder.SetDllNameForExportDirectoryTable(outputFileSimpleName);
}

if (_sectionBuilder.FindSection(R2RPEBuilder.RelocSectionName) == null)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We create the section builder and add any sections above - there's no need to check if the reloc section already exists.

@elinor-fung elinor-fung merged commit 9a6481d into dotnet:main May 28, 2025
94 checks passed
@elinor-fung elinor-fung deleted the r2rpebuilder-deadCode branch May 28, 2025 02:52
@github-actions github-actions bot locked and limited conversation to collaborators Jun 27, 2025
Copilot AI added a commit that referenced this pull request Feb 12, 2026
…with empty SafeArray type name

When a MarshalAs blob contains NATIVE_TYPE_SAFEARRAY with a zero-length
user-defined type name, the native GetMarshalAs returned a non-null pointer
despite having zero bytes. The managed code then used
CreateReadOnlySpanFromNullTerminated to decode this pointer, reading past
the blob into garbage memory, producing a garbled string that failed type
resolution with TypeLoadException.

Fix: Return NULL from native code when byte count is 0 for
safeArrayUserDefinedSubType, marshalType, and marshalCookie. Also add
try/catch around safeArrayUserDefinedType resolution for defense-in-depth,
matching the existing pattern for marshalTypeRef.

Fixes #115953

Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants