Skip to content

Commit

Permalink
🐛 Fix pinning of memory mapped file buffers beyond the first byte.
Browse files Browse the repository at this point in the history
This is the main reason for corruption of GIF images uploaded to Kraken Z. (Simply would not occur for images smaller than 2MB)
  • Loading branch information
hexawyz committed Feb 8, 2025
1 parent 16c783c commit 521408b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Exo/Core/Exo.Memory/MemoryMappedFileMemoryManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ protected override void Dispose(bool disposing)

public override MemoryHandle Pin(int elementIndex = 0)
{
ArgumentOutOfRangeException.ThrowIfGreaterThan((uint)elementIndex, (uint)_length, nameof(elementIndex));
byte* pointer = null;
_viewHandle.AcquirePointer(ref pointer);
return new MemoryHandle(pointer, pinnable: this);
return new MemoryHandle(pointer + (uint)elementIndex, pinnable: this);
}

public override void Unpin() => _viewHandle.ReleasePointer();
Expand Down

0 comments on commit 521408b

Please sign in to comment.