[vlc-devel] [PATCH 1/2] stream: fix off-by-one

RĂ©mi Denis-Courmont remi at remlab.net
Sun Nov 12 12:42:09 CET 2017


One byte is (potentially) needed to append the final nul.
---
 src/input/stream.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/input/stream.c b/src/input/stream.c
index affc7b2c0d..07f3f886f7 100644
--- a/src/input/stream.c
+++ b/src/input/stream.c
@@ -318,7 +318,7 @@ char *vlc_stream_ReadLine( stream_t *s )
 
             /* iconv */
             /* UTF-8 needs at most 150% of the buffer as many as UTF-16 */
-            i_new_line = i_line * 3 / 2;
+            i_new_line = i_line * 3 / 2 + 1;
             psz_new_line = malloc( i_new_line );
             if( psz_new_line == NULL )
                 goto error;
-- 
2.15.0



More information about the vlc-devel mailing list