diff mbox series

[FFmpeg-devel,5/8] avfilter/asrc_flite: Don't segfault when using list_voices option

Message ID AM7PR03MB6660334F1312C3A6CB237D898FB19@AM7PR03MB6660.eurprd03.prod.outlook.com
State Accepted
Commit 304cc0379870ebf155502069939582f1065ef3b5
Headers show
Series [FFmpeg-devel,1/8] avfilter/vf_w3fdif: Fix segfault on allocation error | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Andreas Rheinhardt Oct. 7, 2021, 9:31 a.m. UTC
Could also happen if initializing flite failed* or if an unknown voice
has been selected or if registering the voice failed.

*: which it currently can't, because it is a no-op.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavfilter/asrc_flite.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Paul B Mahol Oct. 7, 2021, 11:07 a.m. UTC | #1
lgtm
Andreas Rheinhardt Oct. 9, 2021, 12:48 p.m. UTC | #2
Andreas Rheinhardt:
> Could also happen if initializing flite failed* or if an unknown voice
> has been selected or if registering the voice failed.
> 
> *: which it currently can't, because it is a no-op.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavfilter/asrc_flite.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/libavfilter/asrc_flite.c b/libavfilter/asrc_flite.c
> index c861f5c238..0789dd6ff3 100644
> --- a/libavfilter/asrc_flite.c
> +++ b/libavfilter/asrc_flite.c
> @@ -196,10 +196,12 @@ static av_cold void uninit(AVFilterContext *ctx)
>  {
>      FliteContext *flite = ctx->priv;
>  
> -    if (!--flite->voice_entry->usage_count)
> -        flite->voice_entry->unregister_fn(flite->voice);
> -    flite->voice = NULL;
> -    flite->voice_entry = NULL;
> +    if (flite->voice_entry) {
> +        if (!--flite->voice_entry->usage_count)
> +            flite->voice_entry->unregister_fn(flite->voice);
> +        flite->voice = NULL;
> +        flite->voice_entry = NULL;
> +    }
>      delete_wave(flite->wave);
>      flite->wave = NULL;
>  }
> 

Will apply the rest of this patchset tonight unless there are objections.

- Andreas
diff mbox series

Patch

diff --git a/libavfilter/asrc_flite.c b/libavfilter/asrc_flite.c
index c861f5c238..0789dd6ff3 100644
--- a/libavfilter/asrc_flite.c
+++ b/libavfilter/asrc_flite.c
@@ -196,10 +196,12 @@  static av_cold void uninit(AVFilterContext *ctx)
 {
     FliteContext *flite = ctx->priv;
 
-    if (!--flite->voice_entry->usage_count)
-        flite->voice_entry->unregister_fn(flite->voice);
-    flite->voice = NULL;
-    flite->voice_entry = NULL;
+    if (flite->voice_entry) {
+        if (!--flite->voice_entry->usage_count)
+            flite->voice_entry->unregister_fn(flite->voice);
+        flite->voice = NULL;
+        flite->voice_entry = NULL;
+    }
     delete_wave(flite->wave);
     flite->wave = NULL;
 }