Skip to content

Commit

Permalink
prevent dispose buffer in use
Browse files Browse the repository at this point in the history
  • Loading branch information
Lightczx committed Jan 22, 2025
1 parent b53cc8b commit c897d89
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,10 @@ private static unsafe void ReadPacket(PipeStream stream, out YaePacketHeader hea
stream.ReadExactly(new(pHeader, sizeof(YaePacketHeader)));
}

using (IMemoryOwner<byte> owner = MemoryPool<byte>.Shared.Rent(header.ContentLength))
{
Span<byte> span = owner.Memory.Span[..header.ContentLength];
stream.ReadExactly(span);
data = new(header, owner);
}
IMemoryOwner<byte> owner = MemoryPool<byte>.Shared.Rent(header.ContentLength);
Span<byte> span = owner.Memory.Span[..header.ContentLength];
stream.ReadExactly(span);
data = new(header, owner);
}

private YaeData GetDataByKind(NamedPipeServerStream serverStream, YaeDataKind targetKind, CancellationToken token)
Expand Down

0 comments on commit c897d89

Please sign in to comment.