[FFmpeg-devel] [PATCH v3] avformat/tee: Support arbitrary number of slaves

Marton Balint cus at passwd.hu
Sat Jun 25 14:05:23 CEST 2016


On Fri, 17 Jun 2016, sebechlebskyjan at gmail.com wrote:

> From: Jan Sebechlebsky <sebechlebskyjan at gmail.com>
>
> Signed-off-by: Jan Sebechlebsky <sebechlebskyjan at gmail.com>
> ---
> I've missed that - sorry, should be fixed in this patch.
>

[...]

> static int open_slave(AVFormatContext *avf, char *slave, TeeSlave *tee_slave)
> @@ -443,24 +442,26 @@ static int tee_write_header(AVFormatContext *avf)
>     TeeContext *tee = avf->priv_data;
>     unsigned nb_slaves = 0, i;
>     const char *filename = avf->filename;
> -    char *slaves[MAX_SLAVES];
> +    char **slaves = NULL;
>     int ret;
>
>     while (*filename) {
> -        if (nb_slaves == MAX_SLAVES) {
> -            av_log(avf, AV_LOG_ERROR, "Maximum %d slave muxers reached.\n",
> -                   MAX_SLAVES);
> -            ret = AVERROR_PATCHWELCOME;
> -            goto fail;
> -        }
> -        if (!(slaves[nb_slaves++] = av_get_token(&filename, slave_delim))) {
> +        char *slave = av_get_token(&filename, slave_delim);
> +        if (!slave) {
>             ret = AVERROR(ENOMEM);
>             goto fail;
>         }
> +        ret = av_dynarray_add_nofree(&slaves, &nb_slaves, slave);
> +        if (ret < 0)
> +            goto fail;

Aren't you still leaking slave here on error?

Thanks,
Marton


More information about the ffmpeg-devel mailing list