Skip to content

Commit

Permalink
Merge pull request #536 from CreateAndInject/CheckOverlaps
Browse files Browse the repository at this point in the history
Check overlaps
  • Loading branch information
wtfsck committed Jan 15, 2024
2 parents 8f7edaf + a45d40c commit 83a0ac6
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 @@ public sealed class OrigSection : IDisposable {
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 83a0ac6

Please sign in to comment.