diff options
author | Niklas Haas <git@haasn.dev> | 2022-03-08 13:49:03 +0100 |
---|---|---|
committer | Niklas Haas <git@haasn.dev> | 2022-03-08 13:49:03 +0100 |
commit | d936293c4167a6f95cae85282e257bffc41522f3 (patch) | |
tree | 4ae44aa42b6bd60114513dede55cb15a6a99a536 /video/out | |
parent | 803bcaa12bbf0c14071d763afbd3c0df1989ac1f (diff) | |
download | mpv-d936293c4167a6f95cae85282e257bffc41522f3.tar.bz2 mpv-d936293c4167a6f95cae85282e257bffc41522f3.tar.xz |
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)
Diffstat (limited to 'video/out')
-rw-r--r-- | video/out/vo_gpu_next.c | 11 |
1 files changed, 6 insertions, 5 deletions
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) |