vlc/vlc-1.1 | branch: master | KO Myung-Hun <[email protected]> | Sat Oct 13 10:39:27 2012 +0900| [028b5186140c126af9a84aa98d98fed31333af21] | committer: Rémi Denis-Courmont
input: Allocate an enough buffer for UTF-8 Signed-off-by: Rémi Denis-Courmont <[email protected]> (cherry picked from commit f929e866e18a94b1c61b4747e56bcd2d2d818551) > http://git.videolan.org/gitweb.cgi/vlc/vlc-1.1.git/?a=commit;h=028b5186140c126af9a84aa98d98fed31333af21 --- src/input/stream.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/input/stream.c b/src/input/stream.c index aaf7f94..47fdc9d 100644 --- a/src/input/stream.c +++ b/src/input/stream.c @@ -1639,16 +1639,20 @@ char *stream_ReadLine( stream_t *s ) i_line += s->p_text->i_char_width; /* the added \0 */ if( s->p_text->i_char_width > 1 ) { + int i_new_line = 0; size_t i_in = 0, i_out = 0; const char * p_in = NULL; char * p_out = NULL; char * psz_new_line = NULL; /* iconv */ - psz_new_line = malloc( i_line ); + /* UTF-8 needs at most 150% of the buffer as many as UTF-16 */ + i_new_line = i_line * 3 / 2; + psz_new_line = malloc( i_new_line ); if( psz_new_line == NULL ) goto error; - i_in = i_out = (size_t)i_line; + i_in = (size_t)i_line; + i_out = (size_t)i_new_line; p_in = p_line; p_out = psz_new_line; @@ -1659,7 +1663,7 @@ char *stream_ReadLine( stream_t *s ) } free( p_line ); p_line = psz_new_line; - i_line = (size_t)i_line - i_out; /* does not include \0 */ + i_line = (size_t)i_new_line - i_out; /* does not include \0 */ } /* Remove trailing LF/CR */ _______________________________________________ vlc-commits mailing list [email protected] http://mailman.videolan.org/listinfo/vlc-commits
