[vlc-commits] text_renderer: freetype: check fribidi result before using indices
Francois Cartegnie
git at videolan.org
Sun Jul 1 22:55:27 CEST 2018
vlc/vlc-3.0 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Feb 9 11:04:55 2018 +0100| [993c19b77d11bca20f9cc1f2e2ed86e588626909] | committer: Jean-Baptiste Kempf
text_renderer: freetype: check fribidi result before using indices
(cherry picked from commit e4c4962c7466c0135cb879942fa0943d02b7dbc6)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=993c19b77d11bca20f9cc1f2e2ed86e588626909
---
modules/text_renderer/freetype/text_layout.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/modules/text_renderer/freetype/text_layout.c b/modules/text_renderer/freetype/text_layout.c
index 309eccbd46..4946b3254e 100644
--- a/modules/text_renderer/freetype/text_layout.c
+++ b/modules/text_renderer/freetype/text_layout.c
@@ -1089,11 +1089,6 @@ static int LayoutLine( filter_t *p_filter,
return VLC_EGENERIC;
}
- line_desc_t *p_line = NewLine( 1 + i_last_char - i_first_char );
-
- if( !p_line )
- return VLC_ENOMEM;
-
filter_sys_t *p_sys = p_filter->p_sys;
int i_last_run = -1;
run_desc_t *p_run = 0;
@@ -1109,21 +1104,27 @@ static int LayoutLine( filter_t *p_filter,
int i_ul_thickness = 0;
#ifdef HAVE_FRIBIDI
- fribidi_reorder_line( 0, &p_paragraph->p_types[i_first_char],
+ bool b_reordered = ( 0 ==
+ fribidi_reorder_line( 0, &p_paragraph->p_types[i_first_char],
1 + i_last_char - i_first_char,
0, p_paragraph->paragraph_type,
&p_paragraph->p_levels[i_first_char],
- 0, &p_paragraph->pi_reordered_indices[i_first_char] );
+ 0, &p_paragraph->pi_reordered_indices[i_first_char] ) );
#endif
+ line_desc_t *p_line = NewLine( 1 + i_last_char - i_first_char );
+ if( !p_line )
+ return VLC_ENOMEM;
+
for( int i = i_first_char; i <= i_last_char; ++i, ++i_line_index )
{
int i_paragraph_index;
#ifdef HAVE_FRIBIDI
- i_paragraph_index = p_paragraph->pi_reordered_indices[ i ];
-#else
- i_paragraph_index = i;
+ if( b_reordered )
+ i_paragraph_index = p_paragraph->pi_reordered_indices[ i ];
+ else
#endif
+ i_paragraph_index = i;
line_character_t *p_ch = p_line->p_character + i_line_index;
p_ch->p_style = p_paragraph->pp_styles[ i_paragraph_index ];
More information about the vlc-commits
mailing list