[vlc-commits] codec: adpcm: check max channels
Francois Cartegnie
git at videolan.org
Thu Sep 29 11:07:16 CEST 2016
vlc/vlc-2.2 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu Sep 29 11:00:21 2016 +0200| [b9803429fb7e94682a962ac5d633b1e66acbe6c6] | committer: Jean-Baptiste Kempf
codec: adpcm: check max channels
(cherry picked from commit bd85994455bd35e7e83816e65d84b0a873d8ca8d)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.2.git/?a=commit;h=b9803429fb7e94682a962ac5d633b1e66acbe6c6
---
modules/codec/adpcm.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/modules/codec/adpcm.c b/modules/codec/adpcm.c
index 6a6a2cc..a3b9c6d 100644
--- a/modules/codec/adpcm.c
+++ b/modules/codec/adpcm.c
@@ -171,22 +171,19 @@ static int OpenDecoder( vlc_object_t *p_this )
p_sys->prev = NULL;
+ uint8_t i_max_channels = 32;
switch( p_dec->fmt_in.i_codec )
{
case VLC_FOURCC('i','m','a', '4'): /* IMA ADPCM */
- if (p_dec->fmt_in.audio.i_channels > 2) {
- free(p_sys);
- msg_Err(p_dec, "Invalid number of channels %i",
- p_dec->fmt_in.audio.i_channels );
- return VLC_EGENERIC;
- }
p_sys->codec = ADPCM_IMA_QT;
+ i_max_channels = 2;
break;
case VLC_CODEC_ADPCM_IMA_WAV: /* IMA ADPCM */
p_sys->codec = ADPCM_IMA_WAV;
break;
case VLC_CODEC_ADPCM_MS: /* MS ADPCM */
p_sys->codec = ADPCM_MS;
+ i_max_channels = 2;
break;
case VLC_CODEC_ADPCM_DK4: /* Duck DK4 ADPCM */
p_sys->codec = ADPCM_DK4;
@@ -206,6 +203,15 @@ static int OpenDecoder( vlc_object_t *p_this )
break;
}
+ if (p_dec->fmt_in.audio.i_channels > i_max_channels ||
+ p_dec->fmt_in.audio.i_channels == 0)
+ {
+ free(p_sys->prev);
+ free(p_sys);
+ msg_Err( p_dec, "Invalid number of channels %i", p_dec->fmt_in.audio.i_channels );
+ return VLC_EGENERIC;
+ }
+
if( p_dec->fmt_in.audio.i_blockalign <= 0 )
{
p_sys->i_block = (p_sys->codec == ADPCM_IMA_QT) ?
More information about the vlc-commits
mailing list