mirror of
https://github.com/mpv-player/mpv
synced 2024-12-22 06:42:03 +00:00
vo_opengl: fix out-of-bounds access in timer_pool_measure
This was there even before the refactor, but the refactor exposed the bug. I hate C's useless fucking modulo operator so much. I've gotten hit by this exact bug way too many times.
This commit is contained in:
parent
0fe4a492c4
commit
8a4f2f0ac0
@ -293,8 +293,9 @@ struct mp_pass_perf timer_pool_measure(struct timer_pool *pool)
|
||||
if (!pool)
|
||||
return (struct mp_pass_perf){0};
|
||||
|
||||
int last = (pool->sample_idx ? pool->sample_idx : VO_PERF_SAMPLE_COUNT) - 1;
|
||||
struct mp_pass_perf res = {
|
||||
.last = pool->samples[(pool->sample_idx - 1) % VO_PERF_SAMPLE_COUNT],
|
||||
.last = pool->samples[last],
|
||||
.avg = pool->sample_count > 0 ? pool->sum / pool->sample_count : 0,
|
||||
.peak = pool->peak,
|
||||
.count = pool->sample_count,
|
||||
|
Loading…
Reference in New Issue
Block a user