On Fri, 20 Sep 2013, Alexandra Khirnova wrote:

---
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;

You need to set pkt->side_data_elems to 0 if this fails.

-
    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;

I'm not sure, but I'd think we need to set ctx->tok_lens[stream_id] to 0 if this fails. Someone who knows the file needs to confirm it.

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

Reply via email to