Skip to content

Commit

Permalink
fix(lib): remove excess pakfileentry buffer padding
Browse files Browse the repository at this point in the history
Buffer is derived from a resizable MemoryStream buffer, so gets padded
up. For text data, this results in a bunch of a NULs. Buffer is readonly
unless replaced entirely, so we can just limit it to the size of the
uncompressed zip data.
  • Loading branch information
tsa96 committed Jan 31, 2025
1 parent 35a72d4 commit aca7c3e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Lumper.Lib/BSP/Struct/PakFileEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public ReadOnlySpan<byte> GetData()
{
lock (ZipAccessLock)
{
using var mem = new MemoryStream(); // Note MemoryStream disposal doesn't delete underlying buffer
using var mem = new MemoryStream((int)ZipEntry!.Size); // Note MemoryStream disposal doesn't delete underlying buffer
using Stream zipStream = ZipEntry!.OpenEntryStream();
zipStream.CopyTo(mem);
_buffer = mem.GetBuffer();
Expand Down

0 comments on commit aca7c3e

Please sign in to comment.