libobs: Fix overflow subtracting unsigned numbers

When offset_size is greater than size, size would overflow
This commit is contained in:
Exeldro 2022-02-10 19:13:43 +01:00 committed by Jim
parent f8c2ccc2c3
commit 0751416db0

View File

@ -1086,13 +1086,15 @@ static inline void push_back_audio(struct obs_encoder *encoder,
struct audio_data *data, size_t size,
size_t offset_size)
{
if (offset_size >= size)
return;
size -= offset_size;
/* push in to the circular buffer */
if (size)
for (size_t i = 0; i < encoder->planes; i++)
circlebuf_push_back(&encoder->audio_input_buffer[i],
data->data[i] + offset_size, size);
for (size_t i = 0; i < encoder->planes; i++)
circlebuf_push_back(&encoder->audio_input_buffer[i],
data->data[i] + offset_size, size);
}
static inline size_t calc_offset_size(struct obs_encoder *encoder,