Commit 6ca2e8ca authored by Jean-Paul Saman's avatar Jean-Paul Saman Committed by Jean-Baptiste Kempf

input stats: handle malloc error

Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent 601832ac
......@@ -174,6 +174,9 @@ void stats_Update( counter_t *p_counter, uint64_t val, uint64_t *new_val )
p_counter->last_update = now;
/* Insert the new one at the beginning */
p_new = (counter_sample_t*)malloc( sizeof( counter_sample_t ) );
if (unlikely(p_new == NULL))
return; /* NOTE: Losing sample here */
p_new->value = val;
p_new->date = p_counter->last_update;
INSERT_ELEM( p_counter->pp_samples, p_counter->i_samples,
......@@ -192,6 +195,9 @@ void stats_Update( counter_t *p_counter, uint64_t val, uint64_t *new_val )
{
counter_sample_t *p_new = (counter_sample_t*)malloc(
sizeof( counter_sample_t ) );
if (unlikely(p_new == NULL))
return; /* NOTE: Losing sample here */
p_new->value = 0;
INSERT_ELEM( p_counter->pp_samples, p_counter->i_samples,
......
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