diff options
author | Kacper Michajłow <kasper93@gmail.com> | 2023-04-29 18:26:41 +0200 |
---|---|---|
committer | Niklas Haas <github-daiK1o@haasn.dev> | 2023-05-25 16:25:33 +0200 |
commit | 19c5cd92b2584b1f21848cb3d409078ce08a5fdf (patch) | |
tree | 7f8ad81c60c16cf3eb897be15f6d520982f12dc2 /video | |
parent | 3b89a58af77189751944bb8297182ef4f5460db5 (diff) | |
download | mpv-19c5cd92b2584b1f21848cb3d409078ce08a5fdf.tar.bz2 mpv-19c5cd92b2584b1f21848cb3d409078ce08a5fdf.tar.xz |
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.
Diffstat (limited to 'video')
-rw-r--r-- | video/out/vo_gpu_next.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/video/out/vo_gpu_next.c b/video/out/vo_gpu_next.c index ae2a370050..9158479a7c 100644 --- a/video/out/vo_gpu_next.c +++ b/video/out/vo_gpu_next.c @@ -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; |