vo_gpu_next: add size guard for pass->num_samples

This shouldn't happen as the array sizes are the same, but guard against
it in case libplacebo do something naughty.
This commit is contained in:
Kacper Michajłow 2023-04-29 18:26:41 +02:00 committed by Niklas Haas
parent 3b89a58af7
commit 19c5cd92b2
1 changed files with 3 additions and 2 deletions

View File

@ -759,11 +759,12 @@ static void info_callback(void *priv, const struct pl_render_info *info)
struct mp_pass_perf *perf = &frame->perf[index];
const struct pl_dispatch_info *pass = info->pass;
static_assert(VO_PERF_SAMPLE_COUNT >= MP_ARRAY_SIZE(pass->samples), "");
assert(pass->num_samples <= MP_ARRAY_SIZE(pass->samples));
pthread_mutex_lock(&p->perf_lock);
memcpy(perf->samples, pass->samples, pass->num_samples * sizeof(pass->samples[0]));
perf->count = pass->num_samples;
perf->count = MPMIN(pass->num_samples, VO_PERF_SAMPLE_COUNT);
memcpy(perf->samples, pass->samples, perf->count * sizeof(pass->samples[0]));
perf->last = pass->last;
perf->peak = pass->peak;
perf->avg = pass->average;