[FFmpeg-cvslog] avcodec/truemotion2: use av_reallocp_array() and check return value

Paul B Mahol git at videolan.org
Mon Sep 9 13:57:45 CEST 2013


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Mon Sep  9 11:28:54 2013 +0000| [6e07bb36393f03d16b792738196ae045fc24acb6] | committer: Paul B Mahol

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 at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6e07bb36393f03d16b792738196ae045fc24acb6
---

 libavcodec/truemotion2.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavcodec/truemotion2.c b/libavcodec/truemotion2.c
index 9d96039..840b993 100644
--- a/libavcodec/truemotion2.c
+++ b/libavcodec/truemotion2.c
@@ -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) {



More information about the ffmpeg-cvslog mailing list