static int append_to_cached_buf(AVCodecContext *avctx,

                                const uint8_t *buf, int buf_size)

{

    DVDSubContext *ctx = avctx->priv_data;



    if (ctx->buf_size > 0xffff - buf_size) {

        av_log(avctx, AV_LOG_WARNING, "Attempt to reconstruct "

               "too large SPU packets aborted.\n");

        av_freep(&ctx->buf);

        return AVERROR_INVALIDDATA;

    }

    ctx->buf = av_realloc(ctx->buf, ctx->buf_size + buf_size);

    if (!ctx->buf)

        return AVERROR(ENOMEM);

    memcpy(ctx->buf + ctx->buf_size, buf, buf_size);

    ctx->buf_size += buf_size;

    return 0;

}

static int append_to_cached_buf(AVCodecContext *avctx,

                                const uint8_t *buf, int buf_size)

{

    DVDSubContext *ctx = avctx->priv_data;



    if (ctx->buf_size > 0xffff - buf_size) {

        av_log(avctx, AV_LOG_WARNING, "Attempt to reconstruct "

               "too large SPU packets aborted.\n");

        av_freep(&ctx->buf);

        return AVERROR_INVALIDDATA;

    }

    ctx->buf = av_realloc(ctx->buf, ctx->buf_size + buf_size);

    if (!ctx->buf)

        return AVERROR(ENOMEM);

    memcpy(ctx->buf + ctx->buf_size, buf, buf_size);

    ctx->buf_size += buf_size;

    return 0;

}

    if (ctx->buf_size > 0xffff - buf_size) {         av_freep(&ctx->buf);     ctx->buf = av_realloc(ctx->buf, ctx->buf_size + buf_size);     if (!ctx->buf)         return AVERROR(ENOMEM);
static int FUNC_0(AVCodecContext *VAR_0,

                                const uint8_t *VAR_1, int VAR_2)

{

    DVDSubContext *ctx = VAR_0->priv_data;



    if (ctx->VAR_2 > 0xffff - VAR_2) {

        av_log(VAR_0, AV_LOG_WARNING, "Attempt to reconstruct "

               "too large SPU packets aborted.\n");

        av_freep(&ctx->VAR_1);

        return AVERROR_INVALIDDATA;

    }

    ctx->VAR_1 = av_realloc(ctx->VAR_1, ctx->VAR_2 + VAR_2);

    if (!ctx->VAR_1)

        return AVERROR(ENOMEM);

    memcpy(ctx->VAR_1 + ctx->VAR_2, VAR_1, VAR_2);

    ctx->VAR_2 += VAR_2;

    return 0;

}

static int FUNC_0(AVCodecContext *VAR_0,
const uint8_t *VAR_1, int VAR_2)
{ DVDSubContext *ctx = VAR_0->priv_data; if (ctx->VAR_2 > 0xffff - VAR_2) { av_log(VAR_0, AV_LOG_WARNING, "Attempt to reconstruct "
"too large SPU packets aborted.\n"); av_freep(&ctx->VAR_1); return AVERROR_INVALIDDATA; } ctx->VAR_1 = av_realloc(ctx->VAR_1, ctx->VAR_2 + VAR_2); if (!ctx->VAR_1)
return AVERROR(ENOMEM); memcpy(ctx->VAR_1 + ctx->VAR_2, VAR_1, VAR_2); ctx->VAR_2 += VAR_2; return 0; }