ARDA64
Index and count must refer to a location within the buffer. How to solve (Parameter 'bytes') error
error: DEBUG] Unexpected error from 64.202.184.249: System.ArgumentOutOfRangeException: Index and count must refer to a location within the buffer. (Parameter 'bytes')
at System.Text.UTF8Encoding.GetString(Byte[] bytes, Int32 index, Int32 count)
at Supercell.Laser.Titan.DataStream.ByteStream.ReadString(Int32 maxCapacity) in C:\Users\Administrator\Desktop\time brawl\src\Supercell.Laser.Titan\DataStream\ByteStream.cs:line 214
at normal code public string ReadString(int maxCapacity = 9000000)
{
int length = this.ReadBytesLength();
if (length <= -1)
{
return null;
}
else
{
if (length <= maxCapacity)
{
string value = Encoding.UTF8.GetString(this.Buffer, this.Offset, length);
this.Offset += length;
return value;
}
return null;
}
} fix: public string ReadString(int maxCapacity = 9000000)
{
int length = this.ReadBytesLength();
if (length <= 0 || length > maxCapacity) // Negatif veya çok büyük değerleri engelle
{
return null;
}
if (this.Offset + length > this.Buffer.Length) // Buffer sınırlarını kontrol et
{
Console.WriteLine("HATA: Geçersiz uzunluk veya buffer sınırı aşıldı!");
return null;
}
string value = Encoding.UTF8.GetString(this.Buffer, this.Offset, length);
this.Offset += length;
return value;
}
129 replies