summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2023-01-12 16:43:44 -0600
committersfan5 <sfan5@live.de>2023-01-24 16:39:33 +0100
commit8ddc0e8888e2ab2d7e50eafb12d8ea51cf1212c2 (patch)
tree9cad6152e39c01230152224f8dc7d0512df20d5f
parent46cd82a68db3f9d4f8afdd756893ccc995299293 (diff)
downloadmpv-8ddc0e8888e2ab2d7e50eafb12d8ea51cf1212c2.tar.bz2
mpv-8ddc0e8888e2ab2d7e50eafb12d8ea51cf1212c2.tar.xz
audio: fix crash during uninit on ao_lavc
The buffer state can be null when using --ao=lavc, so just check it first. Fixes #10175.
-rw-r--r--audio/out/buffer.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/audio/out/buffer.c b/audio/out/buffer.c
index 11bd14f733..48ae984798 100644
--- a/audio/out/buffer.c
+++ b/audio/out/buffer.c
@@ -459,7 +459,7 @@ void ao_uninit(struct ao *ao)
{
struct buffer_state *p = ao->buffer_state;
- if (p->thread_valid) {
+ if (p && p->thread_valid) {
pthread_mutex_lock(&p->pt_lock);
p->terminate = true;
pthread_cond_broadcast(&p->pt_wakeup);
@@ -472,17 +472,19 @@ void ao_uninit(struct ao *ao)
if (ao->driver_initialized)
ao->driver->uninit(ao);
- talloc_free(p->filter_root);
- talloc_free(p->queue);
- talloc_free(p->pending);
- talloc_free(p->convert_buffer);
- talloc_free(p->temp_buf);
+ if (p) {
+ talloc_free(p->filter_root);
+ talloc_free(p->queue);
+ talloc_free(p->pending);
+ talloc_free(p->convert_buffer);
+ talloc_free(p->temp_buf);
- pthread_cond_destroy(&p->wakeup);
- pthread_mutex_destroy(&p->lock);
+ pthread_cond_destroy(&p->wakeup);
+ pthread_mutex_destroy(&p->lock);
- pthread_cond_destroy(&p->pt_wakeup);
- pthread_mutex_destroy(&p->pt_lock);
+ pthread_cond_destroy(&p->pt_wakeup);
+ pthread_mutex_destroy(&p->pt_lock);
+ }
talloc_free(ao);
}