[vlc-commits] access: dvb: scan: do checked alloc/reallocs

Francois Cartegnie git at videolan.org
Sun Apr 10 13:56:10 CEST 2016


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Apr  6 14:45:51 2016 +0200| [f67156940f7809ebfd08edb20f16e2ebdc60462d] | committer: Francois Cartegnie

access: dvb: scan: do checked alloc/reallocs

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

 modules/access/dvb/scan.c |   13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/modules/access/dvb/scan.c b/modules/access/dvb/scan.c
index e436f59..5a1ca1e 100644
--- a/modules/access/dvb/scan.c
+++ b/modules/access/dvb/scan.c
@@ -279,6 +279,13 @@ static int ScanDvbSNextFast( scan_t *p_scan, scan_configuration_t *p_cfg, double
         if( f )
         {
             scan_dvbs_transponder_t *p_transponders = malloc( sizeof( scan_dvbs_transponder_t ) );
+            if( !p_transponders )
+            {
+                fclose( f );
+                free( psz_path );
+                return VLC_ENOMEM;
+            }
+
             char type;
             char psz_fec[3];
 
@@ -306,7 +313,11 @@ static int ScanDvbSNextFast( scan_t *p_scan, scan_configuration_t *p_cfg, double
 
                 p_scan->i_transponders++;
 
-                p_transponders = xrealloc(p_transponders, ( p_scan->i_transponders + 1 ) * sizeof( scan_dvbs_transponder_t ) );
+                scan_dvbs_transponder_t *p_realloc = realloc( p_transponders, ( p_scan->i_transponders + 1 ) * sizeof(*p_realloc) );
+                if( p_realloc )
+                    p_transponders = p_realloc;
+                else
+                    res = EOF;
             } while (res != EOF);
 
             msg_Dbg( p_scan->p_obj, "parsed %d transponders from config", p_scan->i_transponders);



More information about the vlc-commits mailing list