Fixed crash

This commit is contained in:
DeadlySurprise
2015-05-11 17:41:21 +02:00
parent 648dc31e24
commit 35445775c2
2 changed files with 8 additions and 2 deletions

View File

@@ -187,7 +187,9 @@ namespace OpenRA.FileFormats
{
case "SND0":
case "SND2":
if (audioChannels == 1)
if (audioChannels == 0)
throw new NotSupportedException();
else if (audioChannels == 1)
{
var rawAudio = stream.ReadBytes((int)length);
audio1.Write(rawAudio);
@@ -198,11 +200,15 @@ namespace OpenRA.FileFormats
audio1.Write(rawAudio);
rawAudio = stream.ReadBytes((int)length / 2);
audio2.Write(rawAudio);
if (length % 2 != 0)
stream.ReadBytes(2);
}
compressed = type == "SND2";
break;
default:
if (length + stream.Position > stream.Length)
throw new NotSupportedException("Vqa uses unknown Subtype: {0}".F(type));
stream.ReadBytes((int)length);
break;
}