[vlc-commits] [Git][videolan/vlc][master] 4 commits: demux: wav|mkv: don't use the last item of pi_channels_aout

Steve Lhomme (@robUx4) gitlab at videolan.org
Wed Sep 2 12:39:57 UTC 2026



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
6f91f583 by Steve Lhomme at 2026-09-02T12:26:46+00:00
demux: wav|mkv: don't use the last item of pi_channels_aout

The last element is set to 0 because it's used in aout_CheckChannelReorder().
And it might decrement i_missing for an element we should not test.

Fixes #30063

- - - - -
a959890c by Steve Lhomme at 2026-09-02T12:26:46+00:00
demux: wav|mkv: remove redundant test in the loop

- - - - -
7c3fb2b8 by Steve Lhomme at 2026-09-02T12:26:46+00:00
windows_audio: don't use the last element of pi_channels_src

It's always 0.

- - - - -
c52356f1 by Steve Lhomme at 2026-09-02T12:26:46+00:00
demux: wav|mkv: reduce scope of invalid test

We can move up the check in the block that is already handling match < p_fmt->audio.i_channels.
And then we're just checking the mask has been fully handled.

- - - - -


3 changed files:

- modules/demux/mkv/matroska_segment_parse.cpp
- modules/demux/wav.c
- modules/demux/windows_audio_commons.h


Changes:

=====================================
modules/demux/mkv/matroska_segment_parse.cpp
=====================================
@@ -2006,24 +2006,20 @@ bool matroska_segment_c::TrackInit( mkv_track_t * p_tk )
                                     }
                                 }
                                 /* Well fill up with what we can */
-                                for( unsigned i = 0; i < ARRAY_SIZE(pi_channels_aout) && i_missing > 0; i++ )
+                                for( unsigned i = 0; pi_channels_aout[i] && i_missing > 0; i++ )
                                 {
                                     if( !( i_channel_mask & pi_channels_aout[i] ) )
                                     {
                                         i_channel_mask |= pi_channels_aout[i];
                                         i_missing--;
-
-                                        if( i_missing <= 0 )
-                                            break;
                                     }
                                 }
 
-                                match = p_fmt->audio.i_channels - i_missing;
-                            }
-                            if( match < p_fmt->audio.i_channels )
-                            {
-                                msg_Err( vars.p_demuxer, "Invalid/unsupported channel mask" );
-                                i_channel_mask = 0;
+                                if( i_missing > 0 )
+                                {
+                                    msg_Err( vars.p_demuxer, "Invalid/unsupported channel mask" );
+                                    i_channel_mask = 0;
+                                }
                             }
                         }
 


=====================================
modules/demux/wav.c
=====================================
@@ -449,24 +449,20 @@ static int ChunkParseFmt( demux_t *p_demux, uint32_t i_size )
                     }
                 }
                 /* Well fill up with what we can */
-                for( unsigned i = 0; i < ARRAY_SIZE(pi_channels_aout) && i_missing > 0; i++ )
+                for( unsigned i = 0; pi_channels_aout[i] && i_missing > 0; i++ )
                 {
                     if( !( p_sys->i_channel_mask & pi_channels_aout[i] ) )
                     {
                         p_sys->i_channel_mask |= pi_channels_aout[i];
                         i_missing--;
-
-                        if( i_missing <= 0 )
-                            break;
                     }
                 }
 
-                i_match = p_sys->fmt.audio.i_channels - i_missing;
-            }
-            if( i_match < p_sys->fmt.audio.i_channels )
-            {
-                msg_Err( p_demux, "Invalid/unsupported channel mask" );
-                p_sys->i_channel_mask = 0;
+                if( i_missing > 0 )
+                {
+                    msg_Err( p_demux, "Invalid/unsupported channel mask" );
+                    p_sys->i_channel_mask = 0;
+                }
             }
         }
     }


=====================================
modules/demux/windows_audio_commons.h
=====================================
@@ -46,7 +46,7 @@ static inline unsigned getChannelMask( uint32_t * wvfextChannelMask, int i_chann
     unsigned i_channel_mask = 0;
     *i_match = 0;
     for( unsigned i = 0;
-         i < sizeof(pi_channels_src)/sizeof(*pi_channels_src) &&
+         pi_channels_src[i] &&
          *i_match < i_channels; i++ )
     {
         if( *wvfextChannelMask & pi_channels_src[i] )



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/618a236d93702381f10ca1b0481c3048bdf9a515...c52356f14ee57e3002066ef8834591d1cbfd479d

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/618a236d93702381f10ca1b0481c3048bdf9a515...c52356f14ee57e3002066ef8834591d1cbfd479d
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help




More information about the vlc-commits mailing list