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

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