[vlc-commits] demux: avi: fix unchecked calloc

Francois Cartegnie git at videolan.org
Sun Nov 13 21:01:05 CET 2016


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sun Nov 13 20:14:20 2016 +0100| [6c58ce84f8b315480bd4be1797bed6a177ea95ab] | committer: Francois Cartegnie

demux: avi: fix unchecked calloc

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

 modules/demux/avi/avi.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/modules/demux/avi/avi.c b/modules/demux/avi/avi.c
index 95a273d..0820d88 100644
--- a/modules/demux/avi/avi.c
+++ b/modules/demux/avi/avi.c
@@ -665,15 +665,16 @@ static int Open( vlc_object_t * p_this )
                      * directly after BITMAPINFORHEADER in the BITMAPINFO structure */
                     if( fmt.i_extra > 0 )
                     {
-                        const uint8_t *p_pal = fmt.p_extra;
-
                         fmt.video.p_palette = calloc( 1, sizeof(video_palette_t) );
-                        fmt.video.p_palette->i_entries = __MIN(fmt.i_extra/4, 256);
-
-                        for( int k = 0; k < fmt.video.p_palette->i_entries; k++ )
+                        if( likely(fmt.video.p_palette) )
                         {
-                            for( int j = 0; j < 4; j++ )
-                                fmt.video.p_palette->palette[k][j] = p_pal[4*k+j];
+                            const uint8_t *p_pal = fmt.p_extra;
+                            fmt.video.p_palette->i_entries = __MIN(fmt.i_extra/4, 256);
+                            for( int k = 0; k < fmt.video.p_palette->i_entries; k++ )
+                            {
+                                for( int j = 0; j < 4; j++ )
+                                    fmt.video.p_palette->palette[k][j] = p_pal[4*k+j];
+                            }
                         }
                     }
                 }



More information about the vlc-commits mailing list