From eba292f4b954a86b58de435da9c2ea35b6bf8b51 Mon Sep 17 00:00:00 2001 From: qiaohaijiao1 Date: Fri, 2 Feb 2024 18:29:36 +0800 Subject: [PATCH] sim/alsa: add ptr check in _stop Signed-off-by: qiaohaijiao1 --- arch/sim/src/sim/posix/sim_alsa.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/arch/sim/src/sim/posix/sim_alsa.c b/arch/sim/src/sim/posix/sim_alsa.c index fbb8808917..440ef37993 100644 --- a/arch/sim/src/sim/posix/sim_alsa.c +++ b/arch/sim/src/sim/posix/sim_alsa.c @@ -560,11 +560,17 @@ static int sim_audio_stop(struct audio_lowerhalf_s *dev) priv->dev.upper(priv->dev.priv, AUDIO_CALLBACK_COMPLETE, NULL, OK); #endif - apb_free(priv->aux); - priv->aux = NULL; + if (priv->aux) + { + apb_free(priv->aux); + priv->aux = NULL; + } - priv->ops->uninit(priv->codec); - priv->ops = NULL; + if (priv->ops) + { + priv->ops->uninit(priv->codec); + priv->ops = NULL; + } return 0; }