[vlc-commits] linsys_hdsdi: Simplify & fix potential FPE

Hugo Beauzée-Luyssen git at videolan.org
Wed Nov 22 16:01:12 CET 2017


vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Wed Nov 22 15:30:21 2017 +0100| [557d7491cde27e9e682cc29f5e98879d3f9de5a3] | committer: Hugo Beauzée-Luyssen

linsys_hdsdi: Simplify & fix potential FPE

CID #1048724

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

 modules/access/linsys/linsys_hdsdi.c | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)

diff --git a/modules/access/linsys/linsys_hdsdi.c b/modules/access/linsys/linsys_hdsdi.c
index 2ebcb73370..ed60e3c4c2 100644
--- a/modules/access/linsys/linsys_hdsdi.c
+++ b/modules/access/linsys/linsys_hdsdi.c
@@ -181,21 +181,13 @@ static int Open( vlc_object_t *p_this )
         return VLC_ENOMEM;
 
     /* HDSDI AR */
-    char *psz_ar = var_InheritString( p_demux, "linsys-hdsdi-aspect-ratio" );
-    if ( psz_ar != NULL )
-    {
-        psz_parser = strchr( psz_ar, ':' );
-        if ( psz_parser )
-        {
-            *psz_parser++ = '\0';
-            p_sys->i_forced_aspect = p_sys->i_aspect =
-                 strtol( psz_ar, NULL, 0 ) * VOUT_ASPECT_FACTOR
-                 / strtol( psz_parser, NULL, 0 );
-        }
-        else
-            p_sys->i_forced_aspect = 0;
-        free( psz_ar );
-    }
+    unsigned int i_num, i_den;
+    if ( !var_InheritURational( p_demux, &i_num, &i_den,
+                               "linsys-hdsdi-aspect-ratio" ) && i_den != 0 )
+        p_sys->i_forced_aspect = p_sys->i_aspect =
+                i_num * VOUT_ASPECT_FACTOR / i_den;
+    else
+        p_sys->i_forced_aspect = 0;
 
     /* */
     p_sys->i_id_video = var_InheritInteger( p_demux, "linsys-hdsdi-id-video" );



More information about the vlc-commits mailing list