[vlc-commits] [Git][videolan/vlc][master] 2 commits: audio_filter/chorus_flanger: fix realloc() missing sizeof(float)

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Sun Mar 15 15:32:40 UTC 2026



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
983185a9 by Abhinav Aswin at 2026-03-15T16:06:51+01:00
audio_filter/chorus_flanger: fix realloc() missing sizeof(float)
realloc() was passed i_bufferLength as a byte count, but
i_bufferLength is a count of floats. This caused the buffer
to be allocated 4x too small, leading to potential heap
corruption when delay parameters are changed at runtime.

- - - - -
68804388 by Abhinav Aswin at 2026-03-15T16:06:51+01:00
audio_filter/chorus_flanger: zero-initialize expanded buffer after realloc

- - - - -


1 changed file:

- modules/audio_filter/chorus_flanger.c


Changes:

=====================================
modules/audio_filter/chorus_flanger.c
=====================================
@@ -391,10 +391,11 @@ static int paramCallback( vlc_object_t *p_this, char const *psz_var,
 
 static int reallocate_buffer( filter_t *p_filter,  filter_sys_t *p_sys )
 {
+    int i_old_length = p_sys->i_bufferLength;
     p_sys->i_bufferLength = p_sys->i_channels * ( (int)( ( p_sys->f_delayTime
            + p_sys->f_sweepDepth ) * p_filter->fmt_in.audio.i_rate/1000 ) + 1 );
 
-    float *temp = realloc( p_sys->p_delayLineStart, p_sys->i_bufferLength );
+    float *temp = vlc_reallocarray( p_sys->p_delayLineStart, p_sys->i_bufferLength, sizeof( float ) );
     if( unlikely( !temp ) )
     {
         msg_Err( p_filter, "Couldn't reallocate buffer for new delay." );
@@ -402,5 +403,8 @@ static int reallocate_buffer( filter_t *p_filter,  filter_sys_t *p_sys )
     }
     p_sys->p_delayLineStart = temp;
     p_sys->p_delayLineEnd = p_sys->p_delayLineStart + p_sys->i_bufferLength;
+    if( p_sys->i_bufferLength > i_old_length )
+        memset( p_sys->p_delayLineStart + i_old_length, 0,
+                ( p_sys->i_bufferLength - i_old_length ) * sizeof( float ) );
     return 1;
 }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/c7507cdc4b006f6c543c9fafb4b3e1880ebc2554...68804388f3e961f1740898a947e5955522d27b4e

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/c7507cdc4b006f6c543c9fafb4b3e1880ebc2554...68804388f3e961f1740898a947e5955522d27b4e
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list