Allocation-safe asset reading

Try to not pre-allocate memory during asset reading
This commit is contained in:
VaDiM
2025-07-24 04:06:33 +03:00
parent 925f5c12a3
commit 35b24990c6
40 changed files with 617 additions and 706 deletions
+9
View File
@@ -1,4 +1,5 @@
using System;
using System.IO;
namespace AssetStudio
{
@@ -16,6 +17,8 @@ namespace AssetStudio
public UnityVersion version => assetsFile.version;
public long Remaining => byteStart + byteSize - Position;
public ObjectReader(EndianBinaryReader reader, SerializedFile assetsFile, ObjectInfo objectInfo) : base(reader.BaseStream, reader.Endian)
{
this.assetsFile = assetsFile;
@@ -36,6 +39,12 @@ namespace AssetStudio
m_Version = assetsFile.header.m_Version;
}
public void ThrowIfTooLarge(float val)
{
if (val < 0 || val > Remaining)
throw new EndOfStreamException();
}
public void Reset()
{
Position = byteStart;