Merge pull request #7531 from RoosterDragon/stream-read-fixes
Fix some broken Stream.Read calls.
This commit is contained in:
@@ -315,7 +315,7 @@ namespace OpenRA.FileFormats
|
|||||||
// Full frame-modifier
|
// Full frame-modifier
|
||||||
case "CBFZ":
|
case "CBFZ":
|
||||||
var decodeMode = s.Peek() == 0;
|
var decodeMode = s.Peek() == 0;
|
||||||
s.Read(fileBuffer, 0, subchunkLength);
|
s.ReadBytes(fileBuffer, 0, subchunkLength);
|
||||||
Array.Clear(cbf, 0, cbf.Length);
|
Array.Clear(cbf, 0, cbf.Length);
|
||||||
Array.Clear(cbfBuffer, 0, cbfBuffer.Length);
|
Array.Clear(cbfBuffer, 0, cbfBuffer.Length);
|
||||||
var decodeCount = 0;
|
var decodeCount = 0;
|
||||||
@@ -386,7 +386,7 @@ namespace OpenRA.FileFormats
|
|||||||
return;
|
return;
|
||||||
case "VPRZ":
|
case "VPRZ":
|
||||||
Array.Clear(origData, 0, origData.Length);
|
Array.Clear(origData, 0, origData.Length);
|
||||||
s.Read(fileBuffer, 0, subchunkLength);
|
s.ReadBytes(fileBuffer, 0, subchunkLength);
|
||||||
if (fileBuffer[0] != 0)
|
if (fileBuffer[0] != 0)
|
||||||
vtprSize = Format80.DecodeInto(fileBuffer, origData);
|
vtprSize = Format80.DecodeInto(fileBuffer, origData);
|
||||||
else
|
else
|
||||||
@@ -394,7 +394,7 @@ namespace OpenRA.FileFormats
|
|||||||
return;
|
return;
|
||||||
case "VPTR":
|
case "VPTR":
|
||||||
Array.Clear(origData, 0, origData.Length);
|
Array.Clear(origData, 0, origData.Length);
|
||||||
s.Read(origData, 0, subchunkLength);
|
s.ReadBytes(origData, 0, subchunkLength);
|
||||||
vtprSize = subchunkLength;
|
vtprSize = subchunkLength;
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ namespace OpenRA
|
|||||||
|
|
||||||
public static void ReadBytes(this Stream s, byte[] buffer, int offset, int count)
|
public static void ReadBytes(this Stream s, byte[] buffer, int offset, int count)
|
||||||
{
|
{
|
||||||
|
if (count < 0)
|
||||||
|
throw new ArgumentOutOfRangeException("count", "Non-negative number required.");
|
||||||
while (count > 0)
|
while (count > 0)
|
||||||
{
|
{
|
||||||
int bytesRead;
|
int bytesRead;
|
||||||
|
|||||||
Reference in New Issue
Block a user