[vlc-commits] codec: webvtt: fix memstream usage #21326

Francois Cartegnie git at videolan.org
Wed Jan 15 15:11:25 CET 2020


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Jan 15 14:42:42 2020 +0100| [87da5d76191c343b98ba9ab1c9fbea60f23182e8] | committer: Francois Cartegnie

codec: webvtt: fix memstream usage #21326

broken CSS rendering outside of Nix(es)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=87da5d76191c343b98ba9ab1c9fbea60f23182e8
---

 modules/codec/webvtt/subsvtt.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/modules/codec/webvtt/subsvtt.c b/modules/codec/webvtt/subsvtt.c
index f2e1e160eb..3e98acd499 100644
--- a/modules/codec/webvtt/subsvtt.c
+++ b/modules/codec/webvtt/subsvtt.c
@@ -1952,6 +1952,7 @@ struct parser_ctx
     webvtt_region_t *p_region;
 #ifdef HAVE_CSS
     struct vlc_memstream css;
+    bool b_css_memstream_opened;
 #endif
     decoder_t *p_dec;
 };
@@ -1978,7 +1979,7 @@ static void ParserHeaderHandler( void *priv, enum webvtt_header_line_e s,
             ctx->p_region = NULL;
         }
 #ifdef HAVE_CSS
-        else if( ctx->css.stream )
+        else if( ctx->b_css_memstream_opened )
         {
             if( vlc_memstream_close( &ctx->css ) == VLC_SUCCESS )
             {
@@ -2011,7 +2012,7 @@ static void ParserHeaderHandler( void *priv, enum webvtt_header_line_e s,
                 ctx->p_region = webvtt_region_New();
 #ifdef HAVE_CSS
             else if( s == WEBVTT_HEADER_STYLE )
-                (void) vlc_memstream_open( &ctx->css );
+                ctx->b_css_memstream_opened = !vlc_memstream_open( &ctx->css );
 #endif
             return;
         }
@@ -2020,7 +2021,7 @@ static void ParserHeaderHandler( void *priv, enum webvtt_header_line_e s,
     if( s == WEBVTT_HEADER_REGION && ctx->p_region )
         webvtt_region_Parse( ctx->p_region, (char*) psz_line );
 #ifdef HAVE_CSS
-    else if( s == WEBVTT_HEADER_STYLE && ctx->css.stream )
+    else if( s == WEBVTT_HEADER_STYLE && ctx->b_css_memstream_opened )
     {
         vlc_memstream_puts( &ctx->css, psz_line );
         vlc_memstream_putc( &ctx->css, '\n' );
@@ -2039,7 +2040,7 @@ static void LoadExtradata( decoder_t *p_dec )
 
    struct parser_ctx ctx;
 #ifdef HAVE_CSS
-   ctx.css.stream = NULL;
+   ctx.b_css_memstream_opened = false;
 #endif
    ctx.p_region = NULL;
    ctx.p_dec = p_dec;



More information about the vlc-commits mailing list