Fix a NULL deref in delete_rvoice_mixer_threads() (#641)

The function attempts to lock a mutex that might have not been created yet, due to a previous error.
This commit is contained in:
Tom M 2020-04-30 19:49:58 +02:00 committed by GitHub
parent ff14432cd9
commit e2d435dad6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1266,6 +1266,11 @@ fluid_render_loop_multithread(fluid_rvoice_mixer_t *mixer, int current_blockcoun
static void delete_rvoice_mixer_threads(fluid_rvoice_mixer_t *mixer)
{
int i;
// if no threads have been created yet (e.g. because a previous error prevented creation of threads
// mutexes and condition variables), skip terminating threads
if(mixer->thread_count != 0)
{
fluid_atomic_int_set(&mixer->threads_should_terminate, 1);
// Signal threads to wake up
fluid_cond_mutex_lock(mixer->wakeup_threads_m);
@ -1288,6 +1293,7 @@ static void delete_rvoice_mixer_threads(fluid_rvoice_mixer_t *mixer)
fluid_mixer_buffers_free(&mixer->threads[i]);
}
}
FLUID_FREE(mixer->threads);
mixer->thread_count = 0;