Browse Source

cea708: use 4-byte stride for 4-byte character cells

Fixes corruption/OOB.
Fixes #29326
pull/192/head
Stanislav Fort 5 months ago
committed by Thomas Guillem
parent
commit
8c0c8804e1
  1. 13
      modules/codec/cea708.c

13
modules/codec/cea708.c

@ -674,8 +674,11 @@ static void CEA708_Window_Scroll( cea708_window_t *p_w )
cea708_text_row_t *row = p_w->rows[i];
if( row->lastcol < row->firstcol ) /* should not happen */
continue;
memmove( &row->characters[row->firstcol + 1], &row->characters[row->firstcol],
(row->lastcol - row->firstcol + 1) * 4U );
size_t start = (size_t) row->firstcol * 4U;
size_t count = (size_t) (row->lastcol - row->firstcol + 1) * 4U;
memmove( &row->characters[start + 4U], &row->characters[start],
count );
memmove( &row->styles[row->firstcol + 1], &row->styles[row->firstcol],
(row->lastcol - row->firstcol + 1) * sizeof(cea708_pen_style_t) );
row->firstcol++;
@ -695,8 +698,10 @@ static void CEA708_Window_Scroll( cea708_window_t *p_w )
continue;
if( row->firstcol > 0 )
{
memmove( &row->characters[row->firstcol - 1], &row->characters[row->firstcol],
(row->lastcol - row->firstcol + 1) * 4U );
size_t start = (size_t) row->firstcol * 4U;
size_t count = (size_t) (row->lastcol - row->firstcol + 1) * 4U;
memmove( &row->characters[start -4U], &row->characters[start],
count );
memmove( &row->styles[row->firstcol - 1], &row->styles[row->firstcol],
(row->lastcol - row->firstcol + 1) * sizeof(cea708_pen_style_t) );
row->firstcol--;

Loading…
Cancel
Save