[11/17] avconv: Make sure the encoder exists before inspecting supported_list

Message ID 1362578206-2806-11-git-send-email-martin@martin.st
State Committed
Commit e760e1d408261566814e24c43119d7aca538d2eb
Headers show

Commit Message

Martin Storsjö March 6, 2013, 1:56 p.m.
This fixes crashes in cases with many disabled components.
---
 avconv_filter.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Luca Barbato March 6, 2013, 2:50 p.m. | #1
On 06/03/13 14:56, Martin Storsjö wrote:
> This fixes crashes in cases with many disabled components.
> ---
>  avconv_filter.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 

Ok, how to trigger btw?

lu
Anton Khirnov March 6, 2013, 4:12 p.m. | #2
On Wed,  6 Mar 2013 15:56:40 +0200, Martin Storsjö <martin@martin.st> wrote:
> This fixes crashes in cases with many disabled components.

This fixes crashes when there is no encoder for the default codec of selected
format.

> ---
>  avconv_filter.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/avconv_filter.c b/avconv_filter.c
> index cad68e2..2065cb0 100644
> --- a/avconv_filter.c
> +++ b/avconv_filter.c
> @@ -41,7 +41,7 @@ static char *choose_ ## var ## s(OutputStream *ost)                            \
>      if (ost->st->codec->var != none) {                                         \
>          get_name(ost->st->codec->var);                                         \
>          return av_strdup(name);                                                \
> -    } else if (ost->enc->supported_list) {                                     \
> +    } else if (ost->enc && ost->enc->supported_list) {                         \
>          const type *p;                                                         \
>          AVIOContext *s = NULL;                                                 \
>          uint8_t *ret;                                                          \
> -- 
> 1.7.9.4

Patch itself ok.

Patch

diff --git a/avconv_filter.c b/avconv_filter.c
index cad68e2..2065cb0 100644
--- a/avconv_filter.c
+++ b/avconv_filter.c
@@ -41,7 +41,7 @@  static char *choose_ ## var ## s(OutputStream *ost)                            \
     if (ost->st->codec->var != none) {                                         \
         get_name(ost->st->codec->var);                                         \
         return av_strdup(name);                                                \
-    } else if (ost->enc->supported_list) {                                     \
+    } else if (ost->enc && ost->enc->supported_list) {                         \
         const type *p;                                                         \
         AVIOContext *s = NULL;                                                 \
         uint8_t *ret;                                                          \