Fix NREs in QueryDevices by bailing out early.

This commit is contained in:
Matthias Mailänder
2016-04-24 20:49:24 +02:00
parent 149271f71e
commit e47383a4fa

View File

@@ -56,6 +56,12 @@ namespace OpenRA.Platforms.Default
var devices = new List<string>();
var next = ALC10.alcGetString(IntPtr.Zero, type);
if (next == IntPtr.Zero || AL10.alGetError() != AL10.AL_NO_ERROR)
{
Log.Write("sound", "Failed to query OpenAL device list using {0}", label);
return new string[] { };
}
do
{
var str = Marshal.PtrToStringAnsi(next);
@@ -63,12 +69,6 @@ namespace OpenRA.Platforms.Default
devices.Add(str);
} while (Marshal.ReadByte(next) != 0);
if (AL10.alGetError() != AL10.AL_NO_ERROR)
{
Log.Write("sound", "Failed to query OpenAL device list using {0}", label);
return new string[] { };
}
return devices.ToArray();
}