Don't crash when parsing corrupt sound files
Log the exception and move to the next parser.
This commit is contained in:
@@ -175,8 +175,22 @@ namespace OpenRA.FileFormats
|
||||
{
|
||||
channels = sampleBits = sampleRate = 0;
|
||||
|
||||
if (!LoadSound(stream, out rawData))
|
||||
try
|
||||
{
|
||||
if (!LoadSound(stream, out rawData))
|
||||
return false;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// LoadSound() will check if the stream is in a format that this parser supports.
|
||||
// If not, it will simply return false so we know we can't use it. If it is, it will start
|
||||
// parsing the data without any further failsafes, which means that it will crash on corrupted files
|
||||
// (that end prematurely or otherwise don't conform to the specifications despite the headers being OK).
|
||||
Log.Write("debug", "Failed to parse AUD file {0}. Error message:".F(fileName));
|
||||
Log.Write("debug", e.ToString());
|
||||
rawData = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
channels = 1;
|
||||
sampleBits = 16;
|
||||
|
||||
Reference in New Issue
Block a user