1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 17:47:29 +08:00
osu-lazer/osu.Game/IO/Archives
Bartłomiej Dach e57d7d1205
Fix MemoryStreamArchiveReader.GetStream() failing in some cases
`MemoryStreamArchiveReader` introduced in
0657b55196 would previously use
`MemoryStream.GetBuffer()` to retrieve the underlying byte buffer with
stream data. However, this is not generally the method you would want,
for two reasons:

1. It can fail if the stream wasn't created in the way that supports it.
2. As per

	https://learn.microsoft.com/en-us/dotnet/api/system.io.memorystream.getbuffer?view=net-7.0#system-io-memorystream-getbuffer,

   it will return the _raw_ contents of the buffer, including
   potentially unused bytes.

To fix, use `MemoryStream.ToArray()` instead, which avoids both
pitfalls. Notably, `ToArray()` always returns the full contents of the
buffer, regardless of `Position`, as documented in:

    https://learn.microsoft.com/en-us/dotnet/api/system.io.memorystream.toarray?view=net-7.0#system-io-memorystream-toarray
2023-09-18 11:50:36 +02:00
..
ArchiveReader.cs Automated #nullable processing 2022-06-17 16:37:17 +09:00
ByteArrayArchiveReader.cs Rename ArchiveReader implementations to read better 2023-09-14 13:36:07 +09:00
DirectoryArchiveReader.cs Rename ArchiveReader implementations to read better 2023-09-14 13:36:07 +09:00
MemoryStreamArchiveReader.cs Fix MemoryStreamArchiveReader.GetStream() failing in some cases 2023-09-18 11:50:36 +02:00
SingleFileArchiveReader.cs Rename ArchiveReader implementations to read better 2023-09-14 13:36:07 +09:00
ZipArchiveReader.cs Return null intead of FileNotFoundException on missing file in ZipArchiveReader 2023-08-03 09:01:11 +09:00