Commit de1aedd6 authored by Christophe Mutricy's avatar Christophe Mutricy
Browse files

src/misc/stats.c: avoid buffer underflow.

parent ab248b85
...@@ -382,11 +382,13 @@ void stats_CounterClean( counter_t *p_c ) ...@@ -382,11 +382,13 @@ void stats_CounterClean( counter_t *p_c )
int i; int i;
if( p_c ) if( p_c )
{ {
for( i = p_c->i_samples - 1 ; i >= 0 ; i-- ) i = p_c->i_samples - 1 ;
while( i >= 0)
{ {
counter_sample_t *p_s = p_c->pp_samples[i]; counter_sample_t *p_s = p_c->pp_samples[i];
REMOVE_ELEM( p_c->pp_samples, p_c->i_samples, i ); REMOVE_ELEM( p_c->pp_samples, p_c->i_samples, i );
free( p_s ); free( p_s );
i--;
} }
if( p_c->psz_name ) free( p_c->psz_name ); if( p_c->psz_name ) free( p_c->psz_name );
free( p_c ); free( p_c );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment