From fcbf19b764a9f6fed1db6a1d79a2f2f3fa1338d6 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Wed, 28 Apr 2021 21:04:47 +0200 Subject: [PATCH] AAudio: make sure stream is not null to prevent crash in RequestStop (see #3710) --- src/audio/aaudio/SDL_aaudio.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/audio/aaudio/SDL_aaudio.c b/src/audio/aaudio/SDL_aaudio.c index f6f265e30..b9cad6b6c 100644 --- a/src/audio/aaudio/SDL_aaudio.c +++ b/src/audio/aaudio/SDL_aaudio.c @@ -165,18 +165,20 @@ aaudio_CloseDevice(_THIS) aaudio_result_t res; LOGI(__func__); - res = ctx.AAudioStream_requestStop(private->stream); - if (res != AAUDIO_OK) { - LOGI("SDL Failed AAudioStream_requestStop %d", res); - SDL_SetError("%s : %s", __func__, ctx.AAudio_convertResultToText(res)); - return; - } + if (private->stream) { + res = ctx.AAudioStream_requestStop(private->stream); + if (res != AAUDIO_OK) { + LOGI("SDL Failed AAudioStream_requestStop %d", res); + SDL_SetError("%s : %s", __func__, ctx.AAudio_convertResultToText(res)); + return; + } - res = ctx.AAudioStream_close(private->stream); - if (res != AAUDIO_OK) { - LOGI("SDL Failed AAudioStreamBuilder_delete %d", res); - SDL_SetError("%s : %s", __func__, ctx.AAudio_convertResultToText(res)); - return; + res = ctx.AAudioStream_close(private->stream); + if (res != AAUDIO_OK) { + LOGI("SDL Failed AAudioStreamBuilder_delete %d", res); + SDL_SetError("%s : %s", __func__, ctx.AAudio_convertResultToText(res)); + return; + } } if (this->iscapture) {