Skip to content

Commit

Permalink
mmal/deinterlace: Avoid overflows on buffer calculation
Browse files Browse the repository at this point in the history
Use signed variables for calculating the buffers to be sent to the component
as negative values may occur.

Signed-off-by: Julian Scheel <[email protected]>
Signed-off-by: Jean-Baptiste Kempf <[email protected]>
  • Loading branch information
julianscheel authored and jbkempf committed Jun 5, 2015
1 parent 3146706 commit 4e8c81f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions modules/hw/mmal/deinterlace.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4e8c81f

Please sign in to comment.