Skip to content

Commit

Permalink
Check overlaps
Browse files Browse the repository at this point in the history
  • Loading branch information
CreateAndInject committed Jan 15, 2024
1 parent 8f7edaf commit a45d40c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/DotNet/Writer/NativeModuleWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,12 @@ void ReuseIfPossible(PESection section, IReuseChunk chunk, RVA origRva, uint ori
if (((uint)origRva & (requiredAlignment - 1)) != 0)
return;

var origEnd = origRva + origSize;
foreach (var reusedChunk in reusedChunks) {
if (origRva < reusedChunk.RVA + reusedChunk.Chunk.GetVirtualSize() && origEnd > reusedChunk.RVA)
return;
}

if (section.Remove(chunk) is null)
throw new InvalidOperationException();
reusedChunks.Add(new ReusedChunkInfo(chunk, origRva));
Expand Down

0 comments on commit a45d40c

Please # to comment.