subtitle: Fix potential heap buffer overflow
authorHugo Beauzée-Luyssen <hugo@beauzee.fr>
Fri, 28 Apr 2017 11:56:46 +0000 (13:56 +0200)
committerHugo Beauzée-Luyssen <hugo@beauzee.fr>
Thu, 18 May 2017 14:02:39 +0000 (16:02 +0200)
Reported-by: Yannay Livneh <yannayl@checkpoint.com>
             Omri Herscovici <omrih@checkpoint.com>
             Omer Gull <omergu@checkpoint.com>

(cherry picked from commit f2b1f9e3538fc30ecc22b90bcb4300f68d703d30)
Signed-off-by: Hugo Beauzée-Luyssen <hugo@beauzee.fr>
modules/demux/subtitle.c

index 05c6988..3e40f28 100644 (file)
@@ -1886,8 +1886,8 @@ static int ParseJSS( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx )
             if( (*(psz_text + 1 ) ) == '~' || (*(psz_text + 1 ) ) == '{' ||
                 (*(psz_text + 1 ) ) == '\\' )
                 psz_text++;
-            else if( *(psz_text + 1 ) == '\r' ||  *(psz_text + 1 ) == '\n' ||
-                     *(psz_text + 1 ) == '\0' )
+            else if( ( *(psz_text + 1 ) == '\r' ||  *(psz_text + 1 ) == '\n' ) &&
+                     *(psz_text + 1 ) != '\0' )
             {
                 psz_text++;
             }