[vlc-commits] [Git][videolan/vlc][master] hxxx_helper: remove VLAs for avcC

Steve Lhomme (@robUx4) gitlab at videolan.org
Thu Oct 22 11:05:39 UTC 2026



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
be276791 by Alexandre Janniaux at 2026-10-22T10:56:03+00:00
hxxx_helper: remove VLAs for avcC

The SPS/PPS/SPSEXT arrays are incorrectly defined when the i_sps_count,
i_pps_count or is_spsext_count are zero, leading to ubsan warnings. We
can make them the same size as the matching container instead so they
have a predefined static size that is always valid.

    ../modules/codec/hxxx_helper.c:715:20: runtime error: variable length array bound evaluates to non-positive value 0
        #0 0x5555555bf5f7 in h264_helper_get_avcc_config ../modules/codec/hxxx_helper.c:715
        #1 0x5555555cadd9 in hxxx_helper_get_extradata_chain ../modules/codec/hxxx_helper.c:778
        #2 0x5555555cae58 in hxxx_helper_get_extradata_block ../modules/codec/hxxx_helper.c:790
        #3 0x5555555b8203 in test_any ../test/modules/codec/hxxx_helper.c:247
        #4 0x5555555b939c in test_annexb ../test/modules/codec/hxxx_helper.c:293
        #5 0x5555555b9b4f in main ../test/modules/codec/hxxx_helper.c:335
        #6 0x7ffff5c2b284 in __libc_start_call_main (/nix/store/jms7zxzm7w1whczwny5m3gkgdjghmi2r-glibc-2.42-51/lib/libc.so.6+0x2b284) (BuildId: 42e795e8858627eb207f0eaa32737fa700483f56)
        #7 0x7ffff5c2b337 in __libc_start_main at GLIBC_2.2.5 (/nix/store/jms7zxzm7w1whczwny5m3gkgdjghmi2r-glibc-2.42-51/lib/libc.so.6+0x2b337) (BuildId: 42e795e8858627eb207f0eaa32737fa700483f56)
        #8 0x5555555b3464 in _start (/home/janniaux/workspace/vlc/repo/build/test/test_modules_codec_hxxx_helper+0x5f464)

    SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../modules/codec/hxxx_helper.c:715:20

- - - - -


1 changed file:

- modules/codec/hxxx_helper.c


Changes:

=====================================
modules/codec/hxxx_helper.c
=====================================
@@ -696,24 +696,24 @@ static block_t *
 h264_helper_get_avcc_config(const struct hxxx_helper *hh)
 {
     const struct hxxx_helper_nal *p_nal;
-    const uint8_t *pp_sps_bufs[hh->h264.i_sps_count];
-    size_t p_sps_sizes[hh->h264.i_sps_count];
+    const uint8_t *pp_sps_bufs[ARRAY_SIZE(hh->h264.sps_list)];
+    size_t p_sps_sizes[ARRAY_SIZE(hh->h264.sps_list)];
     HELPER_FOREACH_NAL_LIST(p_nal, hh->h264.sps_list, hh->h264.i_sps_count)
     {
         pp_sps_bufs[i_nal_found - 1] = p_nal->b->p_buffer;
         p_sps_sizes[i_nal_found - 1] = p_nal->b->i_buffer;
     }
 
-    const uint8_t *pp_pps_bufs[hh->h264.i_pps_count];
-    size_t p_pps_sizes[hh->h264.i_pps_count];
+    const uint8_t *pp_pps_bufs[ARRAY_SIZE(hh->h264.pps_list)];
+    size_t p_pps_sizes[ARRAY_SIZE(hh->h264.pps_list)];
     HELPER_FOREACH_NAL_LIST(p_nal, hh->h264.pps_list, hh->h264.i_pps_count)
     {
         pp_pps_bufs[i_nal_found - 1] = p_nal->b->p_buffer;
         p_pps_sizes[i_nal_found - 1] = p_nal->b->i_buffer;
     }
 
-    const uint8_t *pp_spsext_bufs[hh->h264.i_spsext_count];
-    size_t p_spsext_sizes[hh->h264.i_spsext_count];
+    const uint8_t *pp_spsext_bufs[ARRAY_SIZE(hh->h264.spsext_list)];
+    size_t p_spsext_sizes[ARRAY_SIZE(hh->h264.spsext_list)];
     HELPER_FOREACH_NAL_LIST(p_nal, hh->h264.spsext_list, hh->h264.i_spsext_count)
     {
         pp_spsext_bufs[i_nal_found - 1] = p_nal->b->p_buffer;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/be276791231f96f703de135a8dfa4ba8be83eea5

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/be276791231f96f703de135a8dfa4ba8be83eea5
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