Skip to content
This repository was archived by the owner on May 13, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/bsdiff/BinaryPatchUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ 0 32 Header

int[] I = SuffixSort(oldData);

byte[] db = new byte[newData.Length + 1];
byte[] eb = new byte[newData.Length + 1];
byte[] db = new byte[newData.Length];
byte[] eb = new byte[newData.Length];

int dblen = 0;
int eblen = 0;
Expand Down Expand Up @@ -348,7 +348,10 @@ with control block a set of triples (x,y,z) meaning "add x bytes
bytesToCopy -= actualBytesToCopy;
}

// sanity-check
if (newPosition == newSize)
return;

// sanity-check
if (newPosition + control[1] > newSize)
throw new InvalidOperationException("Corrupt patch.");

Expand Down