---
 libavcodec/avpacket.c    |    5 +----
 libavcodec/pthread.c     |   11 +++++------
 libavcodec/truemotion2.c |    6 ++++--
 libavcodec/vp56.c        |   12 +++++++-----
 libavcodec/xan.c         |   12 +++++++-----
 5 files changed, 24 insertions(+), 22 deletions(-)

diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index c0a0f8c..b6c8209 100644
--- a/libavcodec/avpacket.c
+++ b/libavcodec/avpacket.c
@@ -268,11 +268,8 @@ uint8_t *av_packet_new_side_data(AVPacket *pkt, enum 
AVPacketSideDataType type,
     if ((unsigned)size > INT_MAX - FF_INPUT_BUFFER_PADDING_SIZE)
         return NULL;
 
-    pkt->side_data = av_realloc(pkt->side_data,
-                                (elems + 1) * sizeof(*pkt->side_data));
-    if (!pkt->side_data)
+    if (av_reallocp_array(&pkt->side_data, elems + 1, sizeof(*pkt->side_data)) 
< 0)
         return NULL;
-
     pkt->side_data[elems].data = av_malloc(size + 
FF_INPUT_BUFFER_PADDING_SIZE);
     if (!pkt->side_data[elems].data)
         return NULL;
diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c
index f4795f3..24a8efc 100644
--- a/libavcodec/pthread.c
+++ b/libavcodec/pthread.c
@@ -429,13 +429,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
 
     if (src->slice_count && src->slice_offset) {
         if (dst->slice_count < src->slice_count) {
-            int *tmp = av_realloc(dst->slice_offset, src->slice_count *
-                                  sizeof(*dst->slice_offset));
-            if (!tmp) {
-                av_free(dst->slice_offset);
-                return AVERROR(ENOMEM);
+            int err;
+            if ((err = av_reallocp_array(&dst->slice_offset, src->slice_count,
+                                         sizeof(*dst->slice_offset))) < 0) {
+                dst->slice_count = 0;
+                return err;
             }
-            dst->slice_offset = tmp;
         }
         memcpy(dst->slice_offset, src->slice_offset,
                src->slice_count * sizeof(*dst->slice_offset));
diff --git a/libavcodec/truemotion2.c b/libavcodec/truemotion2.c
index 4d23f56..36f5e60 100644
--- a/libavcodec/truemotion2.c
+++ b/libavcodec/truemotion2.c
@@ -266,7 +266,7 @@ static int tm2_read_stream(TM2Context *ctx, const uint8_t 
*buf, int stream_id, i
 {
     int i, ret;
     int skip = 0;
-    int len, toks, pos;
+    int len, toks, pos, err;
     TM2Codes codes;
     GetByteContext gb;
 
@@ -322,7 +322,9 @@ 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));
+    if ((err = av_reallocp_array(&ctx->tokens[stream_id], toks,
+                                 sizeof(ctx->tokens[stream_id]))) < 0)
+        return err;
     ctx->tok_lens[stream_id] = toks;
     len = bytestream2_get_be32(&gb);
     if (len > 0) {
diff --git a/libavcodec/vp56.c b/libavcodec/vp56.c
index a0cbcd7..b1ddac9 100644
--- a/libavcodec/vp56.c
+++ b/libavcodec/vp56.c
@@ -456,7 +456,7 @@ static int vp56_size_changed(AVCodecContext *avctx)
 {
     VP56Context *s = avctx->priv_data;
     int stride = s->frames[VP56_FRAME_CURRENT]->linesize[0];
-    int i;
+    int i, err;
 
     s->plane_width[0]  = s->plane_width[3]  = avctx->coded_width;
     s->plane_width[1]  = s->plane_width[2]  = avctx->coded_width/2;
@@ -475,10 +475,12 @@ static int vp56_size_changed(AVCodecContext *avctx)
         return -1;
     }
 
-    s->above_blocks = av_realloc(s->above_blocks,
-                                 (4*s->mb_width+6) * sizeof(*s->above_blocks));
-    s->macroblocks = av_realloc(s->macroblocks,
-                                
s->mb_width*s->mb_height*sizeof(*s->macroblocks));
+    if ((err = av_reallocp_array(&s->above_blocks, 4 * s->mb_width + 6,
+                                 sizeof(*s->above_blocks))) < 0)
+        return err;
+    if ((err = av_reallocp_array(&s->macroblocks, s->mb_width * s->mb_height,
+                                 sizeof(*s->macroblocks))) < 0)
+        return err;
     av_free(s->edge_emu_buffer_alloc);
     s->edge_emu_buffer_alloc = av_malloc(16*stride);
     s->edge_emu_buffer = s->edge_emu_buffer_alloc;
diff --git a/libavcodec/xan.c b/libavcodec/xan.c
index ca2e8e0..a995f83 100644
--- a/libavcodec/xan.c
+++ b/libavcodec/xan.c
@@ -512,7 +512,7 @@ static int xan_decode_frame(AVCodecContext *avctx,
         unsigned *tmpptr;
         uint32_t new_pal;
         int size;
-        int i;
+        int i, err;
         tag  = bytestream2_get_le32(&ctx);
         size = bytestream2_get_be32(&ctx);
         size = FFMIN(size, bytestream2_get_bytes_left(&ctx));
@@ -522,10 +522,12 @@ static int xan_decode_frame(AVCodecContext *avctx,
                 return AVERROR_INVALIDDATA;
             if (s->palettes_count >= PALETTES_MAX)
                 return AVERROR_INVALIDDATA;
-            tmpptr = av_realloc(s->palettes,
-                                (s->palettes_count + 1) * AVPALETTE_SIZE);
-            if (!tmpptr)
-                return AVERROR(ENOMEM);
+            tmpptr = s->palettes;
+            if ((err = av_reallocp_array(&tmpptr, s->palettes_count + 1,
+                                         AVPALETTE_SIZE)) < 0) {
+                s->palettes_count = 0;
+                return err;
+            }
             s->palettes = tmpptr;
             tmpptr += s->palettes_count * AVPALETTE_COUNT;
             for (i = 0; i < PALETTE_COUNT; i++) {
-- 
1.7.10.4

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to