From 1e41b3fbd42f5f6dc2f70ef6755dbd869521a554 Mon Sep 17 00:00:00 2001 From: Nikos Kastellanos Date: Mon, 5 Sep 2016 09:07:39 +0300 Subject: [PATCH] Validate blockAlign can be cast to short --- Source/SharpDX/Multimedia/WaveFormatAdpcm.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Source/SharpDX/Multimedia/WaveFormatAdpcm.cs b/Source/SharpDX/Multimedia/WaveFormatAdpcm.cs index 598dfc5a7..76c2207bb 100644 --- a/Source/SharpDX/Multimedia/WaveFormatAdpcm.cs +++ b/Source/SharpDX/Multimedia/WaveFormatAdpcm.cs @@ -56,6 +56,11 @@ public WaveFormatAdpcm(int rate, int channels, int blockAlign = 0) : base(rate, blockAlign = 1024; } + if (rate <= 0) throw new ArgumentOutOfRangeException("rate", "Must be > 0"); + if (channels <= 0) throw new ArgumentOutOfRangeException("channels", "Must be > 0"); + if (blockAlign <= 0) throw new ArgumentOutOfRangeException("blockAlign", "Must be > 0"); + if (blockAlign > Int16.MaxValue) throw new ArgumentOutOfRangeException("blockAlign", "Must be < 32767"); + waveFormatTag = WaveFormatEncoding.Adpcm; this.blockAlign = (short)blockAlign;