Skip to content

mux: mpeg: guarantee non-overflow in the function

Fixes the bunch of warnings:

    In file included from ../../modules/mux/mpeg/tables.c:44:
    In function ‘bits_write’,
        inlined from ‘GetPMTmpeg4’ at ../../modules/mux/mpeg/tables.c:220:9,
        inlined from ‘BuildPMT’ at ../../modules/mux/mpeg/tables.c:478:13:
    ../../modules/mux/mpeg/bits.h:69:48: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
       69 |             p_buffer->p_data[p_buffer->i_data] |= p_buffer->i_mask;
          |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
    ../../modules/mux/mpeg/tables.c: In function ‘BuildPMT’:
    ../../modules/mux/mpeg/tables.c:181:13: note: at offset 4096 into destination object ‘iod’ of size 4096
      181 |     uint8_t iod[4096];
          |             ^~~
    In function ‘bits_write’,
        inlined from ‘GetPMTmpeg4’ at ../../modules/mux/mpeg/tables.c:220:9,
        inlined from ‘BuildPMT’ at ../../modules/mux/mpeg/tables.c:478:13:
    ../../modules/mux/mpeg/bits.h:69:48: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
       69 |             p_buffer->p_data[p_buffer->i_data] |= p_buffer->i_mask;
          |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
    ../../modules/mux/mpeg/tables.c: In function ‘BuildPMT’:
    ../../modules/mux/mpeg/tables.c:181:13: note: at offset 4096 into destination object ‘iod’ of size 4096
      181 |     uint8_t iod[4096];
          |             ^~~
    ...

Merge request reports