Don't leak memory in the speex resampler wrapper if something goes bad

This commit is contained in:
nattthebear 2016-12-11 20:02:16 -05:00
parent 871c16028a
commit 010fb01bf8
1 changed files with 11 additions and 2 deletions

View File

@ -400,8 +400,17 @@ namespace BizHawk.Emulation.Common
public void Dispose()
{
LibSpeexDSP.speex_resampler_destroy(st);
st = IntPtr.Zero;
if (st != IntPtr.Zero)
{
LibSpeexDSP.speex_resampler_destroy(st);
st = IntPtr.Zero;
GC.SuppressFinalize(this);
}
}
~SpeexResampler()
{
Dispose();
}
void InternalDrain(short[] buf, int nsamp)