From d936293c4167a6f95cae85282e257bffc41522f3 Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Tue, 8 Mar 2022 13:49:03 +0100 Subject: vo_gpu_next: fix crash when disabling DR at runtime This code fails if we have DR buffers, but none of them correspond to the current frame. Normally only happens if e.g. changing the decoder at runtime, since DR buffers are not properly reinit in that case. (Arguably a separate bug) --- video/out/vo_gpu_next.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'video/out') diff --git a/video/out/vo_gpu_next.c b/video/out/vo_gpu_next.c index 4ed33a8a55..39321871eb 100644 --- a/video/out/vo_gpu_next.c +++ b/video/out/vo_gpu_next.c @@ -159,17 +159,18 @@ static void update_lut(struct priv *p, struct user_lut *lut); static pl_buf get_dr_buf(struct priv *p, const uint8_t *ptr) { - pl_buf buf = NULL; pthread_mutex_lock(&p->dr_lock); for (int i = 0; i < p->num_dr_buffers; i++) { - buf = p->dr_buffers[i]; - if (ptr >= buf->data && ptr < buf->data + buf->params.size) - break; + pl_buf buf = p->dr_buffers[i]; + if (ptr >= buf->data && ptr < buf->data + buf->params.size) { + pthread_mutex_unlock(&p->dr_lock); + return buf; + } } pthread_mutex_unlock(&p->dr_lock); - return buf; + return NULL; } static void free_dr_buf(void *opaque, uint8_t *data) -- cgit v1.2.3