static int add_shorts_metadata(int count, const char *name,

                               const char *sep, TiffContext *s)

{

    char *ap;

    int i;

    int16_t *sp;



    if (count >= INT_MAX / sizeof(int16_t) || count <= 0)

        return AVERROR_INVALIDDATA;

    if (bytestream2_get_bytes_left(&s->gb) < count * sizeof(int16_t))

        return AVERROR_INVALIDDATA;



    sp = av_malloc(count * sizeof(int16_t));

    if (!sp)

        return AVERROR(ENOMEM);



    for (i = 0; i < count; i++)

        sp[i] = tget_short(&s->gb, s->le);

    ap = shorts2str(sp, count, sep);

    av_freep(&sp);

    if (!ap)

        return AVERROR(ENOMEM);

    av_dict_set(avpriv_frame_get_metadatap(&s->picture), name, ap, AV_DICT_DONT_STRDUP_VAL);

    return 0;

}

static int add_shorts_metadata(int count, const char *name,

                               const char *sep, TiffContext *s)

{

    char *ap;

    int i;

    int16_t *sp;



    if (count >= INT_MAX / sizeof(int16_t) || count <= 0)

        return AVERROR_INVALIDDATA;

    if (bytestream2_get_bytes_left(&s->gb) < count * sizeof(int16_t))

        return AVERROR_INVALIDDATA;



    sp = av_malloc(count * sizeof(int16_t));

    if (!sp)

        return AVERROR(ENOMEM);



    for (i = 0; i < count; i++)

        sp[i] = tget_short(&s->gb, s->le);

    ap = shorts2str(sp, count, sep);

    av_freep(&sp);

    if (!ap)

        return AVERROR(ENOMEM);

    av_dict_set(avpriv_frame_get_metadatap(&s->picture), name, ap, AV_DICT_DONT_STRDUP_VAL);

    return 0;

}

    av_dict_set(avpriv_frame_get_metadatap(&s->picture), name, ap, AV_DICT_DONT_STRDUP_VAL);                                const char *sep, TiffContext *s)     av_dict_set(avpriv_frame_get_metadatap(&s->picture), name, ap, AV_DICT_DONT_STRDUP_VAL);
static int FUNC_0(int VAR_0, const char *VAR_1,

                               const char *VAR_2, TiffContext *VAR_3)

{

    char *VAR_4;

    int VAR_5;

    int16_t *sp;



    if (VAR_0 >= INT_MAX / sizeof(int16_t) || VAR_0 <= 0)

        return AVERROR_INVALIDDATA;

    if (bytestream2_get_bytes_left(&VAR_3->gb) < VAR_0 * sizeof(int16_t))

        return AVERROR_INVALIDDATA;



    sp = av_malloc(VAR_0 * sizeof(int16_t));

    if (!sp)

        return AVERROR(ENOMEM);



    for (VAR_5 = 0; VAR_5 < VAR_0; VAR_5++)

        sp[VAR_5] = tget_short(&VAR_3->gb, VAR_3->le);

    VAR_4 = shorts2str(sp, VAR_0, VAR_2);

    av_freep(&sp);

    if (!VAR_4)

        return AVERROR(ENOMEM);

    av_dict_set(avpriv_frame_get_metadatap(&VAR_3->picture), VAR_1, VAR_4, AV_DICT_DONT_STRDUP_VAL);

    return 0;

}

static int FUNC_0(int VAR_0, const char *VAR_1,
const char *VAR_2, TiffContext *VAR_3)
{ char *VAR_4; int VAR_5; int16_t *sp; if (VAR_0 >= INT_MAX / sizeof(int16_t) || VAR_0 <= 0)
return AVERROR_INVALIDDATA; if (bytestream2_get_bytes_left(&VAR_3->gb) < VAR_0 * sizeof(int16_t))
return AVERROR_INVALIDDATA; sp = av_malloc(VAR_0 * sizeof(int16_t)); if (!sp)
return AVERROR(ENOMEM); for (VAR_5 = 0; VAR_5 < VAR_0; VAR_5++) sp[VAR_5] = tget_short(&VAR_3->gb, VAR_3->le); VAR_4 = shorts2str(sp, VAR_0, VAR_2); av_freep(&sp); if (!VAR_4)
return AVERROR(ENOMEM); av_dict_set(avpriv_frame_get_metadatap(&VAR_3->picture), VAR_1, VAR_4, AV_DICT_DONT_STRDUP_VAL); return 0; }