[vlc-commits] [Git][videolan/vlc][master] 2 commits: video_filter: dither: use vlc_alloc

Steve Lhomme (@robUx4) gitlab at videolan.org
Thu Apr 9 18:18:17 UTC 2026



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
8c69be05 by François Cartegnie at 2026-04-09T17:43:17+00:00
video_filter: dither: use vlc_alloc

- - - - -
36ad07db by François Cartegnie at 2026-04-09T17:43:17+00:00
video_filter: dither: check for overflow

- - - - -


1 changed file:

- modules/video_filter/dither.c


Changes:

=====================================
modules/video_filter/dither.c
=====================================
@@ -115,6 +115,8 @@ vlc_module_end()
  *****************************************************************************/
 static int Open( filter_t *p_filter )
 {
+    if( p_filter->fmt_in.video.i_width > SIZE_MAX / 3 * 2 )
+        return VLC_EGENERIC;
 
     filter_sys_t *p_sys = malloc( sizeof( filter_sys_t ) );
     if ( !p_sys )
@@ -195,7 +197,7 @@ static int Open( filter_t *p_filter )
     }
 
     // parse colors
-    p_sys->p_palette = malloc( i_num_colors * sizeof( int ) );
+    p_sys->p_palette = vlc_alloc( i_num_colors, sizeof( int ) );
     if ( !p_sys->p_palette )
     {
         msg_Err( p_filter, "Failed to allocate memory for palette" );
@@ -266,16 +268,16 @@ static int Open( filter_t *p_filter )
 
     // allocate dither buffers
     const unsigned int i_width = p_filter->fmt_in.video.i_width;
-    const size_t i_single = i_width * 3 * 2 * sizeof( int );
-    int *p_all = malloc( 3 * i_single );
+    const size_t i_single_in_px = (size_t)i_width * 3 * 2;
+    int *p_all = vlc_alloc( i_single_in_px, 3 * sizeof( int ) );
     if (!p_all) {
         free(p_sys->p_palette);
         free(p_sys);
         return VLC_ENOMEM;
     }
     p_sys->p_dither_buffer[0] = p_all;
-    p_sys->p_dither_buffer[1] = p_all + ( i_single / sizeof ( int ) );
-    p_sys->p_dither_buffer[2] = p_all + ( i_single / sizeof ( int ) ) * 2;
+    p_sys->p_dither_buffer[1] = p_all + i_single_in_px;
+    p_sys->p_dither_buffer[2] = p_all + i_single_in_px * 2;
 
     p_filter->ops = &filter_ops;
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/0d70243ef4f9891524dc98728406831b4f790dd4...36ad07db83b355fd6dae69565eacf862585f1980

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/0d70243ef4f9891524dc98728406831b4f790dd4...36ad07db83b355fd6dae69565eacf862585f1980
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list