[vlc-commits] codec: adpcm: check max channels

Francois Cartegnie git at videolan.org
Thu Sep 29 11:02:17 CEST 2016


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu Sep 29 11:00:21 2016 +0200| [bd85994455bd35e7e83816e65d84b0a873d8ca8d] | committer: Francois Cartegnie

codec: adpcm: check max channels

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=bd85994455bd35e7e83816e65d84b0a873d8ca8d
---

 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 74341a0..e8f2f20 100644
--- a/modules/codec/adpcm.c
+++ b/modules/codec/adpcm.c
@@ -172,22 +172,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;
@@ -207,6 +204,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