From c86e89101c887679029ccfe041850ba1b53944b3 Mon Sep 17 00:00:00 2001 From: Stanislav Fort Date: Mon, 27 Oct 2025 14:25:53 +0100 Subject: [PATCH] cea708: fix CEA708_Window_Truncate() Make truncation actually drop one column in LTR/RTL (adjust lastcol/firstcol; delete rows only when they become empty). Fixes #29328 --- modules/codec/cea708.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/modules/codec/cea708.c b/modules/codec/cea708.c index 2df2f3cf3c..bba6ca19b4 100644 --- a/modules/codec/cea708.c +++ b/modules/codec/cea708.c @@ -605,6 +605,8 @@ static void CEA708_Window_Truncate( cea708_window_t *p_w, int i_direction ) for( int i=p_w->i_firstrow; i <= p_w->i_lastrow; i++ ) { cea708_text_row_t *row = p_w->rows[i]; + if (!row) + continue; if( row->lastcol == i_max ) { if( row->firstcol >= row->lastcol ) @@ -616,6 +618,12 @@ static void CEA708_Window_Truncate( cea708_window_t *p_w, int i_direction ) else if( i == p_w->i_lastrow ) p_w->i_lastrow--; } + else + { + /* Drop rightmost column */ + row->lastcol--; + } + } } } @@ -626,6 +634,8 @@ static void CEA708_Window_Truncate( cea708_window_t *p_w, int i_direction ) for( int i=p_w->i_firstrow; i <= p_w->i_lastrow; i++ ) { cea708_text_row_t *row = p_w->rows[i]; + if (!row) + continue; if( row->firstcol == i_min ) { if( row->firstcol >= row->lastcol ) @@ -637,6 +647,12 @@ static void CEA708_Window_Truncate( cea708_window_t *p_w, int i_direction ) else if( i == p_w->i_lastrow ) p_w->i_lastrow--; } + else + { + /* Drop leftmost column */ + row->firstcol++; + } + } } }