[vlc-commits] decoder: ttml: fix NULL deref and broken logic (cid #1398412)

Francois Cartegnie git at videolan.org
Wed Jan 25 10:56:00 CET 2017


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Jan 25 10:54:27 2017 +0100| [91ea82b7265c06d386e9316ac39bef76e7d3da7b] | committer: Francois Cartegnie

decoder: ttml: fix NULL deref and broken logic (cid #1398412)

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

 modules/codec/ttml/substtml.c | 34 ++++++++++++++++++++--------------
 1 file changed, 20 insertions(+), 14 deletions(-)

diff --git a/modules/codec/ttml/substtml.c b/modules/codec/ttml/substtml.c
index be4762f..b01cf0d 100644
--- a/modules/codec/ttml/substtml.c
+++ b/modules/codec/ttml/substtml.c
@@ -222,22 +222,28 @@ static void FillTextStyle( const char *psz_attr, const char *psz_val,
     {
         char *value = strdup( psz_val );
         char* psz_saveptr = NULL;
-        char* token = strtok_r( value, " ", &psz_saveptr );
+        char* token = (value) ? strtok_r( value, " ", &psz_saveptr ) : NULL;
         // <color>? <length> <length>?
-        bool b_ok = false;
-        unsigned int color = vlc_html_color( token, &b_ok );
-        if( b_ok )
+        if( token != NULL )
         {
-            p_text_style->i_outline_color = color & 0xFFFFFF;
-            p_text_style->i_outline_alpha = (color & 0xFF000000) >> 24;
-            token = strtok_r( NULL, " ", &psz_saveptr );
-        }
-        char* psz_end = NULL;
-        int i_outline_width = strtol( token, &psz_end, 10 );
-        if( psz_end != token )
-        {
-            // Assume unit is pixel, and ignore border radius
-            p_text_style->i_outline_width = i_outline_width;
+            bool b_ok = false;
+            unsigned int color = vlc_html_color( token, &b_ok );
+            if( b_ok )
+            {
+                p_text_style->i_outline_color = color & 0xFFFFFF;
+                p_text_style->i_outline_alpha = (color & 0xFF000000) >> 24;
+                token = strtok_r( NULL, " ", &psz_saveptr );
+                if( token != NULL )
+                {
+                    char* psz_end = NULL;
+                    int i_outline_width = strtol( token, &psz_end, 10 );
+                    if( psz_end != token )
+                    {
+                        // Assume unit is pixel, and ignore border radius
+                        p_text_style->i_outline_width = i_outline_width;
+                    }
+                }
+            }
         }
         free( value );
     }



More information about the vlc-commits mailing list