static int add_file(AVFormatContext *avf, char *filename, ConcatFile **rfile,

                    unsigned *nb_files_alloc)

{

    ConcatContext *cat = avf->priv_data;

    ConcatFile *file;

    char *url;

    size_t url_len;



    if (cat->safe > 0 && !safe_filename(filename)) {

        av_log(avf, AV_LOG_ERROR, "Unsafe file name '%s'\n", filename);

        return AVERROR(EPERM);

    }

    url_len = strlen(avf->filename) + strlen(filename) + 16;

    if (!(url = av_malloc(url_len)))

        return AVERROR(ENOMEM);

    ff_make_absolute_url(url, url_len, avf->filename, filename);

    av_free(filename);



    if (cat->nb_files >= *nb_files_alloc) {

        size_t n = FFMAX(*nb_files_alloc * 2, 16);

        ConcatFile *new_files;

        if (n <= cat->nb_files || n > SIZE_MAX / sizeof(*cat->files) ||

            !(new_files = av_realloc(cat->files, n * sizeof(*cat->files))))

            return AVERROR(ENOMEM);

        cat->files = new_files;

        *nb_files_alloc = n;

    }



    file = &cat->files[cat->nb_files++];

    memset(file, 0, sizeof(*file));

    *rfile = file;



    file->url        = url;

    file->start_time = AV_NOPTS_VALUE;

    file->duration   = AV_NOPTS_VALUE;



    return 0;

}

static int add_file(AVFormatContext *avf, char *filename, ConcatFile **rfile,

                    unsigned *nb_files_alloc)

{

    ConcatContext *cat = avf->priv_data;

    ConcatFile *file;

    char *url;

    size_t url_len;



    if (cat->safe > 0 && !safe_filename(filename)) {

        av_log(avf, AV_LOG_ERROR, "Unsafe file name '%s'\n", filename);

        return AVERROR(EPERM);

    }

    url_len = strlen(avf->filename) + strlen(filename) + 16;

    if (!(url = av_malloc(url_len)))

        return AVERROR(ENOMEM);

    ff_make_absolute_url(url, url_len, avf->filename, filename);

    av_free(filename);



    if (cat->nb_files >= *nb_files_alloc) {

        size_t n = FFMAX(*nb_files_alloc * 2, 16);

        ConcatFile *new_files;

        if (n <= cat->nb_files || n > SIZE_MAX / sizeof(*cat->files) ||

            !(new_files = av_realloc(cat->files, n * sizeof(*cat->files))))

            return AVERROR(ENOMEM);

        cat->files = new_files;

        *nb_files_alloc = n;

    }



    file = &cat->files[cat->nb_files++];

    memset(file, 0, sizeof(*file));

    *rfile = file;



    file->url        = url;

    file->start_time = AV_NOPTS_VALUE;

    file->duration   = AV_NOPTS_VALUE;



    return 0;

}

    char *url;         return AVERROR(EPERM);         return AVERROR(ENOMEM);     av_free(filename);             return AVERROR(ENOMEM);
static int FUNC_0(AVFormatContext *VAR_0, char *VAR_1, ConcatFile **VAR_2,

                    unsigned *VAR_3)

{

    ConcatContext *cat = VAR_0->priv_data;

    ConcatFile *file;

    char *VAR_4;

    size_t url_len;



    if (cat->safe > 0 && !safe_filename(VAR_1)) {

        av_log(VAR_0, AV_LOG_ERROR, "Unsafe file name '%s'\n", VAR_1);

        return AVERROR(EPERM);

    }

    url_len = strlen(VAR_0->VAR_1) + strlen(VAR_1) + 16;

    if (!(VAR_4 = av_malloc(url_len)))

        return AVERROR(ENOMEM);

    ff_make_absolute_url(VAR_4, url_len, VAR_0->VAR_1, VAR_1);

    av_free(VAR_1);



    if (cat->nb_files >= *VAR_3) {

        size_t n = FFMAX(*VAR_3 * 2, 16);

        ConcatFile *new_files;

        if (n <= cat->nb_files || n > SIZE_MAX / sizeof(*cat->files) ||

            !(new_files = av_realloc(cat->files, n * sizeof(*cat->files))))

            return AVERROR(ENOMEM);

        cat->files = new_files;

        *VAR_3 = n;

    }



    file = &cat->files[cat->nb_files++];

    memset(file, 0, sizeof(*file));

    *VAR_2 = file;



    file->VAR_4        = VAR_4;

    file->start_time = AV_NOPTS_VALUE;

    file->duration   = AV_NOPTS_VALUE;



    return 0;

}

static int FUNC_0(AVFormatContext *VAR_0, char *VAR_1, ConcatFile **VAR_2,
unsigned *VAR_3)
{ ConcatContext *cat = VAR_0->priv_data; ConcatFile *file; char *VAR_4; size_t url_len; if (cat->safe > 0 && !safe_filename(VAR_1)) { av_log(VAR_0, AV_LOG_ERROR, "Unsafe file name '%s'\n", VAR_1); return AVERROR(EPERM); } url_len = strlen(VAR_0->VAR_1) + strlen(VAR_1) + 16; if (!(VAR_4 = av_malloc(url_len)))
return AVERROR(ENOMEM); ff_make_absolute_url(VAR_4, url_len, VAR_0->VAR_1, VAR_1); av_free(VAR_1); if (cat->nb_files >= *VAR_3) { size_t n = FFMAX(*VAR_3 * 2, 16); ConcatFile *new_files; if (n <= cat->nb_files || n > SIZE_MAX / sizeof(*cat->files) ||
!(new_files = av_realloc(cat->files, n * sizeof(*cat->files))))
return AVERROR(ENOMEM); cat->files = new_files; *VAR_3 = n; } file = &cat->files[cat->nb_files++]; memset(file, 0, sizeof(*file)); *VAR_2 = file; file->VAR_4        = VAR_4; file->start_time = AV_NOPTS_VALUE; file->duration   = AV_NOPTS_VALUE; return 0; }