avcodec/truemotion2: use av_reallocp_array() and check return value

Also reset tok_lens if reallocation fails.

Fixes #2946.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
Paul B Mahol 2013-09-09 11:28:54 +00:00
parent 7d75fb381b
commit 6e07bb3639
1 changed files with 5 additions and 1 deletions

View File

@ -342,7 +342,11 @@ static int tm2_read_stream(TM2Context *ctx, const uint8_t *buf, int stream_id, i
tm2_free_codes(&codes);
return AVERROR_INVALIDDATA;
}
ctx->tokens[stream_id] = av_realloc(ctx->tokens[stream_id], toks * sizeof(int));
ret = av_reallocp_array(&ctx->tokens[stream_id], toks, sizeof(int));
if (ret < 0) {
ctx->tok_lens[stream_id] = 0;
return ret;
}
ctx->tok_lens[stream_id] = toks;
len = bytestream2_get_be32(&gb);
if (len > 0) {