Commit 4e8c81f9 authored by Julian Scheel's avatar Julian Scheel Committed by Jean-Baptiste Kempf

mmal/deinterlace: Avoid overflows on buffer calculation

Use signed variables for calculating the buffers to be sent to the component
as negative values may occur.
Signed-off-by: default avatarJulian Scheel <julian@jusst.de>
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 3146706d
......@@ -331,10 +331,12 @@ static void fill_output_port(filter_t *filter)
{
filter_sys_t *sys = filter->p_sys;
/* allow at least 2 buffers in transit */
unsigned max_buffers_in_transit = __MAX(sys->output->buffer_num, MIN_NUM_BUFFERS_IN_TRANSIT);
unsigned buffers_available = max_buffers_in_transit - atomic_load(&sys->output_in_transit);
unsigned buffers_to_send = max_buffers_in_transit - sys->output_in_transit;
unsigned i;
unsigned max_buffers_in_transit = __MAX(2, MIN_NUM_BUFFERS_IN_TRANSIT);
int buffers_available = sys->output->buffer_num -
atomic_load(&sys->output_in_transit) -
mmal_queue_length(sys->filtered_pictures);
int buffers_to_send = max_buffers_in_transit - sys->output_in_transit;
int i;
if (buffers_to_send > buffers_available)
buffers_to_send = buffers_available;
......
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