From 35445775c2d2442e5d050cbb20cf165015ba32f6 Mon Sep 17 00:00:00 2001 From: DeadlySurprise Date: Mon, 11 May 2015 17:41:21 +0200 Subject: [PATCH] Fixed crash --- OpenRA.Game/FileFormats/VqaReader.cs | 8 +++++++- OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/OpenRA.Game/FileFormats/VqaReader.cs b/OpenRA.Game/FileFormats/VqaReader.cs index b801392205..630f37a8ae 100644 --- a/OpenRA.Game/FileFormats/VqaReader.cs +++ b/OpenRA.Game/FileFormats/VqaReader.cs @@ -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; } diff --git a/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs index 5e91c1a117..93bd33fe37 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs @@ -304,7 +304,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic if (!GlobalFileSystem.Exists(filename)) return false; - if (Path.GetExtension(filename) == ".vqa") + if (Path.GetExtension(filename).ToLower() == ".vqa") { player = panel.Get("PLAYER"); currentFilename = filename;