Skip to content
Snippets Groups Projects
Commit 3856f9fc authored by Alexandre Janniaux's avatar Alexandre Janniaux Committed by Steve Lhomme
Browse files

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];
          |             ^~~
    ...
parent 5c24c232
No related branches found
No related tags found
1 merge request!5836mux: mpeg: guarantee non-overflow in the function
Pipeline #499602 passed with stage
in 13 minutes and 19 seconds
......@@ -63,6 +63,9 @@ static inline void bits_align( bits_buffer_t *p_buffer )
static inline void bits_write( bits_buffer_t *p_buffer,
int i_count, uint64_t i_bits )
{
if (p_buffer->i_data + i_count < p_buffer->i_size)
return;
while( i_count > 0 )
{
i_count--;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment