[vlc-commits] commit: avi: do not allocate memory of size 0 (if i_extra == 0, p_extra is not released). ( Rémi Duraffort )

git at videolan.org git at videolan.org
Wed Jul 28 21:34:26 CEST 2010


vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Wed Jul 28 20:42:05 2010 +0200| [ba0b10204bf3d5809a16f3ffa2d326ca754c4f4d] | committer: Rémi Duraffort 

avi: do not allocate memory of size 0 (if i_extra == 0, p_extra is not released).

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

 modules/demux/avi/avi.c |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/modules/demux/avi/avi.c b/modules/demux/avi/avi.c
index ebb8f56..a6b9154 100644
--- a/modules/demux/avi/avi.c
+++ b/modules/demux/avi/avi.c
@@ -437,9 +437,12 @@ static int Open( vlc_object_t * p_this )
 
                 fmt.i_extra = __MIN( p_auds->p_wf->cbSize,
                     p_auds->i_chunk_size - sizeof(WAVEFORMATEX) );
-                fmt.p_extra = malloc( fmt.i_extra );
-                if( !fmt.p_extra ) goto error;
-                memcpy( fmt.p_extra, &p_auds->p_wf[1], fmt.i_extra );
+                if( fmt.i_extra > 0 )
+                {
+                    fmt.p_extra = malloc( fmt.i_extra );
+                    if( !fmt.p_extra ) goto error;
+                    memcpy( fmt.p_extra, &p_auds->p_wf[1], fmt.i_extra );
+                }
                 break;
 
             case( AVIFOURCC_vids ):
@@ -512,9 +515,12 @@ static int Open( vlc_object_t * p_this )
                 fmt.i_extra =
                     __MIN( p_vids->p_bih->biSize - sizeof( BITMAPINFOHEADER ),
                            p_vids->i_chunk_size - sizeof(BITMAPINFOHEADER) );
-                fmt.p_extra = malloc( fmt.i_extra );
-                if( !fmt.p_extra ) goto error;
-                memcpy( fmt.p_extra, &p_vids->p_bih[1], fmt.i_extra );
+                if( fmt.i_extra > 0 )
+                {
+                    fmt.p_extra = malloc( fmt.i_extra );
+                    if( !fmt.p_extra ) goto error;
+                    memcpy( fmt.p_extra, &p_vids->p_bih[1], fmt.i_extra );
+                }
 
                 msg_Dbg( p_demux, "stream[%d] video(%4.4s) %"PRIu32"x%"PRIu32" %dbpp %ffps",
                          i, (char*)&p_vids->p_bih->biCompression,



More information about the vlc-commits mailing list