[vlc-devel] commit: Use calloc() instead of malloc() - fixes integer overflow... ( Rémi Denis-Courmont )

git version control git at videolan.org
Mon Mar 3 18:29:24 CET 2008


vlc | branch: master | Rémi Denis-Courmont <rem at videolan.org> | Mon Mar  3 19:27:39 2008 +0200| [783ab03c7bd8ddedcd3dc5bad18efc70a4c57aaa]

Use calloc() instead of malloc() - fixes integer overflow...
...assuming you have non-buggy calloc() implementation.

Pointed-out-by: Drew Yao
Signed-off-by: Rémi Denis-Courmont <rem at videolan.org>

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

 modules/demux/real.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/modules/demux/real.c b/modules/demux/real.c
index 7f0c585..f0f66ae 100644
--- a/modules/demux/real.c
+++ b/modules/demux/real.c
@@ -1240,18 +1240,16 @@ static int ReadCodecSpecificData( demux_t *p_demux, int i_len, int i_num )
                 tk->i_subpackets =
                     i_subpacket_h * i_frame_size / tk->i_subpacket_size;
                 tk->p_subpackets =
-                    malloc( tk->i_subpackets * sizeof(block_t *) );
+                    calloc( tk->i_subpackets, sizeof(block_t *) );
             }
             else if( fmt.i_codec == VLC_FOURCC('2','8','_','8') )
             {
                 tk->i_subpackets =
                     i_subpacket_h * i_frame_size / tk->i_coded_frame_size;
                 tk->p_subpackets =
-                    malloc( tk->i_subpackets * sizeof(block_t *) );
+                    calloc( tk->i_subpackets, sizeof(block_t *) );
             }
 
-            for( i = 0; i < tk->i_subpackets; i++ ) tk->p_subpackets[i] = NULL;
-
             tk->p_es = es_out_Add( p_demux->out, &fmt );
 
             TAB_APPEND( p_sys->i_track, p_sys->track, tk );




More information about the vlc-devel mailing list