---
 libavformat/mpegts.c             |    9 ++++----
 libavformat/mxfdec.c             |   17 +++++++--------
 libavformat/mxfenc.c             |   42 +++++++++++++++++++++++---------------
 libavformat/oggdec.c             |    6 +++---
 libavformat/oggparsetheora.c     |    4 ++--
 libavformat/oggparsevorbis.c     |    2 +-
 libavformat/rdt.c                |    9 ++++----
 libavformat/rtmphttp.c           |    6 ++----
 libavformat/rtmpproto.c          |   34 +++++++++++++++---------------
 libavformat/rtpdec_asf.c         |    8 +++-----
 libavformat/rtpdec_qt.c          |    3 +--
 libavformat/smacker.c            |    6 ++----
 libavformat/smoothstreamingenc.c |    2 +-
 libavformat/utils.c              |   22 ++++++++++----------
 14 files changed, 86 insertions(+), 84 deletions(-)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 1540a8d..a84469a 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -198,10 +198,11 @@ static void clear_programs(MpegTSContext *ts)
 static void add_pat_entry(MpegTSContext *ts, unsigned int programid)
 {
     struct Program *p;
-    void *tmp = av_realloc(ts->prg, (ts->nb_prg+1)*sizeof(struct Program));
-    if(!tmp)
-        return;
-    ts->prg = tmp;
+    av_reallocp_array(&ts->prg, ts->nb_prg + 1, sizeof(struct Program));
+    if (!ts->prg) {
+        ts->nb_prg = 0;
+        return AVERROR(ENOMEM);
+    }
     p = &ts->prg[ts->nb_prg];
     p->id = programid;
     p->nb_pids = 0;
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index d2039f6..929a004 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -410,7 +410,7 @@ static int mxf_read_primer_pack(void *arg, AVIOContext *pb, 
int tag, int size, U
 static int mxf_read_partition_pack(void *arg, AVIOContext *pb, int tag, int 
size, UID uid, int64_t klv_offset)
 {
     MXFContext *mxf = arg;
-    MXFPartition *partition, *tmp_part;
+    MXFPartition *partition;
     UID op;
     uint64_t footer_partition;
     uint32_t nb_essence_containers;
@@ -418,10 +418,11 @@ static int mxf_read_partition_pack(void *arg, AVIOContext 
*pb, int tag, int size
     if (mxf->partitions_count+1 >= UINT_MAX / sizeof(*mxf->partitions))
         return AVERROR(ENOMEM);
 
-    tmp_part = av_realloc(mxf->partitions, (mxf->partitions_count + 1) * 
sizeof(*mxf->partitions));
-    if (!tmp_part)
+    av_reallocp_array(&mxf->partitions, mxf->partitions_count + 1, 
sizeof(*mxf->partitions));
+    if (!mxf->partitions) {
+        mxf->partitions_count = 0;
         return AVERROR(ENOMEM);
-    mxf->partitions = tmp_part;
+    }
 
     if (mxf->parsing_backward) {
         /* insert the new partition pack in the middle
@@ -546,13 +547,13 @@ static int mxf_read_partition_pack(void *arg, AVIOContext 
*pb, int tag, int size
 
 static int mxf_add_metadata_set(MXFContext *mxf, void *metadata_set)
 {
-    MXFMetadataSet **tmp;
     if (mxf->metadata_sets_count+1 >= UINT_MAX / sizeof(*mxf->metadata_sets))
         return AVERROR(ENOMEM);
-    tmp = av_realloc(mxf->metadata_sets, (mxf->metadata_sets_count + 1) * 
sizeof(*mxf->metadata_sets));
-    if (!tmp)
+    av_reallocp_array(&mxf->metadata_sets, mxf->metadata_sets_count + 1, 
sizeof(*mxf->metadata_sets));
+    if (!mxf->metadata_sets) {
+        mxf->metadata_sets_count = 0;
         return AVERROR(ENOMEM);
-    mxf->metadata_sets = tmp;
+    }
     mxf->metadata_sets[mxf->metadata_sets_count] = metadata_set;
     mxf->metadata_sets_count++;
     return 0;
diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index a4403d5..843fcd0 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -1182,7 +1182,7 @@ static void mxf_write_klv_fill(AVFormatContext *s)
     }
 }
 
-static void mxf_write_partition(AVFormatContext *s, int bodysid,
+static int mxf_write_partition(AVFormatContext *s, int bodysid,
                                 int indexsid,
                                 const uint8_t *key, int write_metadata)
 {
@@ -1205,10 +1205,11 @@ static void mxf_write_partition(AVFormatContext *s, int 
bodysid,
     }
 
     if (!memcmp(key, body_partition_key, 16)) {
-        mxf->body_partition_offset =
-            av_realloc(mxf->body_partition_offset,
-                       (mxf->body_partitions_count+1)*
-                       sizeof(*mxf->body_partition_offset));
+        if (av_reallocp_array(&mxf->body_partition_offset, 
mxf->body_partitions_count + 1,
+                              sizeof(*mxf->body_partition_offset)) < 0) {
+            mxf->body_partitions_count = 0;
+            return AVERROR(ENOMEM);
+        }
         mxf->body_partition_offset[mxf->body_partitions_count++] = 
partition_offset;
     }
 
@@ -1273,6 +1274,8 @@ static void mxf_write_partition(AVFormatContext *s, int 
bodysid,
     }
 
     avio_flush(pb);
+
+    return 0;
 }
 
 static const UID mxf_mpeg2_codec_uls[] = {
@@ -1675,11 +1678,11 @@ static int mxf_write_packet(AVFormatContext *s, 
AVPacket *pkt)
     MXFIndexEntry ie = {0};
 
     if (!mxf->edit_unit_byte_count && !(mxf->edit_units_count % 
EDIT_UNITS_PER_BODY)) {
-        mxf->index_entries = av_realloc(mxf->index_entries,
-            (mxf->edit_units_count + 
EDIT_UNITS_PER_BODY)*sizeof(*mxf->index_entries));
+        av_reallocp_array(&mxf->index_entries, mxf->edit_units_count
+                          + EDIT_UNITS_PER_BODY, sizeof(*mxf->index_entries));
         if (!mxf->index_entries) {
             av_log(s, AV_LOG_ERROR, "could not allocate index entries\n");
-            return -1;
+            return AVERROR(ENOMEM);
         }
     }
 
@@ -1692,11 +1695,13 @@ static int mxf_write_packet(AVFormatContext *s, 
AVPacket *pkt)
 
     if (!mxf->header_written) {
         if (mxf->edit_unit_byte_count) {
-            mxf_write_partition(s, 1, 2, header_open_partition_key, 1);
+            if (mxf_write_partition(s, 1, 2, header_open_partition_key, 1))
+                return AVERROR(ENOMEM);
             mxf_write_klv_fill(s);
             mxf_write_index_table_segment(s);
         } else {
-            mxf_write_partition(s, 0, 0, header_open_partition_key, 1);
+            if (mxf_write_partition(s, 0, 0, header_open_partition_key, 1))
+                return AVERROR(ENOMEM);
         }
         mxf->header_written = 1;
     }
@@ -1706,8 +1711,8 @@ static int mxf_write_packet(AVFormatContext *s, AVPacket 
*pkt)
             (!mxf->edit_units_count || mxf->edit_units_count > 
EDIT_UNITS_PER_BODY) &&
             !(ie.flags & 0x33)) { // I frame, Gop start
             mxf_write_klv_fill(s);
-            mxf_write_partition(s, 1, 2, body_partition_key, 0);
-
+            if (mxf_write_partition(s, 1, 2, body_partition_key, 0))
+                return AVERROR(ENOMEM);
             mxf_write_klv_fill(s);
             mxf_write_index_table_segment(s);
         }
@@ -1782,10 +1787,11 @@ static int mxf_write_footer(AVFormatContext *s)
     mxf_write_klv_fill(s);
     mxf->footer_partition_offset = avio_tell(pb);
     if (mxf->edit_unit_byte_count) { // no need to repeat index
-        mxf_write_partition(s, 0, 0, footer_partition_key, 0);
+        if (mxf_write_partition(s, 0, 0, footer_partition_key, 0))
+            return AVERROR(ENOMEM);
     } else {
-        mxf_write_partition(s, 0, 2, footer_partition_key, 0);
-
+        if (mxf_write_partition(s, 0, 2, footer_partition_key, 0))
+            return AVERROR(ENOMEM);
         mxf_write_klv_fill(s);
         mxf_write_index_table_segment(s);
     }
@@ -1796,11 +1802,13 @@ static int mxf_write_footer(AVFormatContext *s)
     if (s->pb->seekable) {
         avio_seek(pb, 0, SEEK_SET);
         if (mxf->edit_unit_byte_count) {
-            mxf_write_partition(s, 1, 2, header_closed_partition_key, 1);
+            if (mxf_write_partition(s, 1, 2, header_closed_partition_key, 1))
+                return AVERROR(ENOMEM);
             mxf_write_klv_fill(s);
             mxf_write_index_table_segment(s);
         } else {
-            mxf_write_partition(s, 0, 0, header_closed_partition_key, 1);
+            if (mxf_write_partition(s, 0, 0, header_closed_partition_key, 1))
+                return AVERROR(ENOMEM);
         }
     }
 
diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index 6514c5b..a647f7b 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -100,15 +100,15 @@ static int ogg_restore(AVFormatContext *s, int discard)
         avio_seek(bc, ost->pos, SEEK_SET);
         ogg->curidx   = ost->curidx;
         ogg->nstreams = ost->nstreams;
-        ogg->streams  = av_realloc(ogg->streams,
-                                   ogg->nstreams * sizeof(*ogg->streams));
+        av_reallocp_array(&ogg->streams, ogg->nstreams, sizeof(*ogg->streams));
 
         if (ogg->streams) {
             memcpy(ogg->streams, ost->streams,
                    ost->nstreams * sizeof(*ogg->streams));
         } else {
-            av_free(old_streams);
             ogg->nstreams = 0;
+            av_free(ost);
+            return AVERROR(ENOMEM);
         }
     }
 
diff --git a/libavformat/oggparsetheora.c b/libavformat/oggparsetheora.c
index ed31d53..da3969b 100644
--- a/libavformat/oggparsetheora.c
+++ b/libavformat/oggparsetheora.c
@@ -123,8 +123,8 @@ theora_header (AVFormatContext * s, int idx)
         return -1;
     }
 
-    st->codec->extradata = av_realloc (st->codec->extradata,
-                                       cds + FF_INPUT_BUFFER_PADDING_SIZE);
+    if (av_reallocp(&st->codec->extradata, cds + FF_INPUT_BUFFER_PADDING_SIZE) 
< 0)
+        return AVERROR(ENOMEM);
     cdp = st->codec->extradata + st->codec->extradata_size;
     *cdp++ = os->psize >> 8;
     *cdp++ = os->psize & 0xff;
diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c
index db462fc..4bb0afd 100644
--- a/libavformat/oggparsevorbis.c
+++ b/libavformat/oggparsevorbis.c
@@ -188,7 +188,7 @@ fixup_vorbis_headers(AVFormatContext * as, struct 
oggvorbis_private *priv,
         offset += priv->len[i];
         av_freep(&priv->packet[i]);
     }
-    *buf = av_realloc(*buf, offset + FF_INPUT_BUFFER_PADDING_SIZE);
+    av_reallocp(buf, offset + FF_INPUT_BUFFER_PADDING_SIZE);
     return offset;
 }
 
diff --git a/libavformat/rdt.c b/libavformat/rdt.c
index a8367e5..894b9d2 100644
--- a/libavformat/rdt.c
+++ b/libavformat/rdt.c
@@ -422,12 +422,11 @@ rdt_parse_sdp_line (AVFormatContext *s, int st_index,
                 int count = s->streams[n]->index + 1;
                 if (first == -1) first = n;
                 if (rdt->nb_rmst < count) {
-                    RMStream **rmst= av_realloc(rdt->rmst, 
count*sizeof(*rmst));
-                    if (!rmst)
+                    av_reallocp(&rdt->rmst, count * sizeof(rdt->rmst));
+                    if (!rdt->rmst)
                         return AVERROR(ENOMEM);
-                    memset(rmst + rdt->nb_rmst, 0,
-                           (count - rdt->nb_rmst) * sizeof(*rmst));
-                    rdt->rmst    = rmst;
+                    memset(rdt->rmst + rdt->nb_rmst, 0,
+                           (count - rdt->nb_rmst) * sizeof(rdt->rmst));
                     rdt->nb_rmst = count;
                 }
                 rdt->rmst[s->streams[n]->index] = ff_rm_alloc_rmstream();
diff --git a/libavformat/rtmphttp.c b/libavformat/rtmphttp.c
index e67abba..fcacf4f 100644
--- a/libavformat/rtmphttp.c
+++ b/libavformat/rtmphttp.c
@@ -85,14 +85,12 @@ static int rtmp_http_send_cmd(URLContext *h, const char 
*cmd)
 static int rtmp_http_write(URLContext *h, const uint8_t *buf, int size)
 {
     RTMP_HTTPContext *rt = h->priv_data;
-    void *ptr;
 
     if (rt->out_size + size > rt->out_capacity) {
         rt->out_capacity = (rt->out_size + size) * 2;
-        ptr = av_realloc(rt->out_data, rt->out_capacity);
-        if (!ptr)
+        av_reallocp(&rt->out_data, rt->out_capacity);
+        if (!rt->out_data)
             return AVERROR(ENOMEM);
-        rt->out_data = ptr;
     }
 
     memcpy(rt->out_data + rt->out_size, buf, size);
diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index 58cedef..5b54cf0 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -148,15 +148,11 @@ static const uint8_t rtmp_server_key[] = {
 
 static int add_tracked_method(RTMPContext *rt, const char *name, int id)
 {
-    void *ptr;
-
     if (rt->nb_tracked_methods + 1 > rt->tracked_methods_size) {
         rt->tracked_methods_size = (rt->nb_tracked_methods + 1) * 2;
-        ptr = av_realloc(rt->tracked_methods,
-                         rt->tracked_methods_size * 
sizeof(*rt->tracked_methods));
-        if (!ptr)
+        av_reallocp(&rt->tracked_methods, rt->tracked_methods_size * 
sizeof(*rt->tracked_methods));
+        if (!rt->tracked_methods)
             return AVERROR(ENOMEM);
-        rt->tracked_methods = ptr;
     }
 
     rt->tracked_methods[rt->nb_tracked_methods].name = av_strdup(name);
@@ -2041,7 +2037,8 @@ static int handle_notify(URLContext *s, RTMPPacket *pkt) {
             rt->flv_off  = 0;
         }
 
-        cp = av_realloc(rt->flv_data, rt->flv_size);
+        cp = rt->flv_data;
+        av_reallocp(&cp, rt->flv_size);
         if (!cp)
             return AVERROR(ENOMEM);
         rt->flv_data = cp;
@@ -2180,14 +2177,16 @@ static int get_packet(URLContext *s, int for_header)
             // generate packet header and put data into buffer for FLV demuxer
             rt->flv_off  = 0;
             rt->flv_size = rpkt.data_size + 15;
-            rt->flv_data = p = av_realloc(rt->flv_data, rt->flv_size);
-            bytestream_put_byte(&p, rpkt.type);
-            bytestream_put_be24(&p, rpkt.data_size);
-            bytestream_put_be24(&p, ts);
-            bytestream_put_byte(&p, ts >> 24);
-            bytestream_put_be24(&p, 0);
-            bytestream_put_buffer(&p, rpkt.data, rpkt.data_size);
-            bytestream_put_be32(&p, 0);
+            av_reallocp(&rt->flv_data, rt->flv_size);
+            if (!rt->flv_data)
+                return AVERROR(ENOMEM);
+            bytestream_put_byte(&rt->flv_data, rpkt.type);
+            bytestream_put_be24(&rt->flv_data, rpkt.data_size);
+            bytestream_put_be24(&rt->flv_data, ts);
+            bytestream_put_byte(&rt->flv_data, ts >> 24);
+            bytestream_put_be24(&rt->flv_data, 0);
+            bytestream_put_buffer(&rt->flv_data, rpkt.data, rpkt.data_size);
+            bytestream_put_be32(&rt->flv_data, 0);
             ff_rtmp_packet_destroy(&rpkt);
             return 0;
         } else if (rpkt.type == RTMP_PT_NOTIFY) {
@@ -2202,7 +2201,7 @@ static int get_packet(URLContext *s, int for_header)
             // we got raw FLV data, make it available for FLV demuxer
             rt->flv_off  = 0;
             rt->flv_size = rpkt.data_size;
-            rt->flv_data = av_realloc(rt->flv_data, rt->flv_size);
+            av_reallocp(&rt->flv_data, rt->flv_size);
             /* rewrite timestamps */
             next = rpkt.data;
             ts = rpkt.timestamp;
@@ -2464,7 +2463,8 @@ reconnect:
     if (rt->is_input) {
         // generate FLV header for demuxer
         rt->flv_size = 13;
-        rt->flv_data = av_realloc(rt->flv_data, rt->flv_size);
+        if (av_reallocp(&rt->flv_data, rt->flv_size) < 0)
+            return AVERROR(ENOMEM);
         rt->flv_off  = 0;
         memcpy(rt->flv_data, "FLV\1\5\0\0\0\011\0\0\0\0", rt->flv_size);
     } else {
diff --git a/libavformat/rtpdec_asf.c b/libavformat/rtpdec_asf.c
index e425650..f26dd19 100644
--- a/libavformat/rtpdec_asf.c
+++ b/libavformat/rtpdec_asf.c
@@ -239,14 +239,12 @@ static int asfrtp_parse_packet(AVFormatContext *s, 
PayloadContext *asf,
 
                 int cur_len = start_off + len_off - off;
                 int prev_len = out_len;
-                void *newmem;
                 out_len += cur_len;
                 if (FFMIN(cur_len, len - off) < 0)
                     return -1;
-                newmem = av_realloc(asf->buf, out_len);
-                if (!newmem)
-                    return -1;
-                asf->buf = newmem;
+                av_reallocp(&asf->buf, out_len);
+                if (!asf->buf)
+                    return AVERROR(ENOMEM);
                 memcpy(asf->buf + prev_len, buf + off,
                        FFMIN(cur_len, len - off));
                 avio_skip(pb, cur_len);
diff --git a/libavformat/rtpdec_qt.c b/libavformat/rtpdec_qt.c
index af5a5e9..b191d17 100644
--- a/libavformat/rtpdec_qt.c
+++ b/libavformat/rtpdec_qt.c
@@ -172,8 +172,7 @@ static int qt_rtp_parse_packet(AVFormatContext *s, 
PayloadContext *qt,
     switch (packing_scheme) {
     case 3: /* one data packet spread over 1 or multiple RTP packets */
         if (qt->pkt.size > 0 && qt->timestamp == *timestamp) {
-            qt->pkt.data = av_realloc(qt->pkt.data, qt->pkt.size + alen +
-                                      FF_INPUT_BUFFER_PADDING_SIZE);
+            av_reallocp(&qt->pkt.data, qt->pkt.size + alen + 
FF_INPUT_BUFFER_PADDING_SIZE);
         } else {
             av_freep(&qt->pkt.data);
             av_init_packet(&qt->pkt);
diff --git a/libavformat/smacker.c b/libavformat/smacker.c
index cd4353a..8802a3f 100644
--- a/libavformat/smacker.c
+++ b/libavformat/smacker.c
@@ -305,7 +305,6 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket 
*pkt)
         for(i = 0; i < 7; i++) {
             if(flags & 1) {
                 uint32_t size;
-                uint8_t *tmpbuf;
 
                 size = avio_rl32(s->pb) - 4;
                 if (!size || size > frame_size) {
@@ -315,10 +314,9 @@ static int smacker_read_packet(AVFormatContext *s, 
AVPacket *pkt)
                 frame_size -= size;
                 frame_size -= 4;
                 smk->curstream++;
-                tmpbuf = av_realloc(smk->bufs[smk->curstream], size);
-                if (!tmpbuf)
+                av_reallocp(&smk->bufs[smk->curstream], size);
+                if (!smk->bufs[smk->curstream])
                     return AVERROR(ENOMEM);
-                smk->bufs[smk->curstream] = tmpbuf;
                 smk->buf_sizes[smk->curstream] = size;
                 ret = avio_read(s->pb, smk->bufs[smk->curstream], size);
                 if(ret != size)
diff --git a/libavformat/smoothstreamingenc.c b/libavformat/smoothstreamingenc.c
index d26af05..292ee0c 100644
--- a/libavformat/smoothstreamingenc.c
+++ b/libavformat/smoothstreamingenc.c
@@ -446,7 +446,7 @@ static int add_fragment(OutputStream *os, const char *file, 
const char *infofile
     Fragment *frag;
     if (os->nb_fragments >= os->fragments_size) {
         os->fragments_size = (os->fragments_size + 1) * 2;
-        os->fragments = av_realloc(os->fragments, 
sizeof(*os->fragments)*os->fragments_size);
+        av_reallocp(&os->fragments, sizeof(*os->fragments) * 
os->fragments_size);
         if (!os->fragments)
             return AVERROR(ENOMEM);
     }
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 80b1ce2..1db9f89 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -265,7 +265,8 @@ int av_probe_input_buffer(AVIOContext *pb, AVInputFormat 
**fmt,
         }
 
         /* read probe data */
-        buf = av_realloc(buf, probe_size + AVPROBE_PADDING_SIZE);
+        if (av_reallocp(&buf, probe_size + AVPROBE_PADDING_SIZE) < 0)
+            return AVERROR(ENOMEM);
         if ((ret = avio_read(pb, buf + buf_offset, probe_size - buf_offset)) < 
0) {
             /* fail if error was not end of file, otherwise, lower score */
             if (ret != AVERROR_EOF) {
@@ -456,7 +457,8 @@ static void probe_codec(AVFormatContext *s, AVStream *st, 
const AVPacket *pkt)
         --st->probe_packets;
 
         if (pkt) {
-            pd->buf = av_realloc(pd->buf, 
pd->buf_size+pkt->size+AVPROBE_PADDING_SIZE);
+            if (av_reallocp(&pd->buf, pd->buf_size + pkt->size + 
AVPROBE_PADDING_SIZE) < 0)
+                return AVERROR(ENOMEM);
             memcpy(pd->buf+pd->buf_size, pkt->data, pkt->size);
             pd->buf_size += pkt->size;
             memset(pd->buf+pd->buf_size, 0, AVPROBE_PADDING_SIZE);
@@ -2565,14 +2567,14 @@ AVStream *avformat_new_stream(AVFormatContext *s, 
AVCodec *c)
 {
     AVStream *st;
     int i;
-    AVStream **streams;
 
-    if (s->nb_streams >= INT_MAX/sizeof(*streams))
+    if (s->nb_streams >= INT_MAX/sizeof(s->streams))
         return NULL;
-    streams = av_realloc(s->streams, (s->nb_streams + 1) * sizeof(*streams));
-    if (!streams)
+    av_reallocp_array(&s->streams, s->nb_streams + 1, sizeof(s->streams));
+    if (!s->streams) {
+        s->nb_streams = 0;
         return NULL;
-    s->streams = streams;
+    }
 
     st = av_mallocz(sizeof(AVStream));
     if (!st)
@@ -2665,7 +2667,6 @@ void ff_program_add_stream_index(AVFormatContext *ac, int 
progid, unsigned int i
 {
     int i, j;
     AVProgram *program=NULL;
-    void *tmp;
 
     if (idx >= ac->nb_streams) {
         av_log(ac, AV_LOG_ERROR, "stream index %d is not valid\n", idx);
@@ -2680,10 +2681,9 @@ void ff_program_add_stream_index(AVFormatContext *ac, 
int progid, unsigned int i
             if(program->stream_index[j] == idx)
                 return;
 
-        tmp = av_realloc(program->stream_index, sizeof(unsigned 
int)*(program->nb_stream_indexes+1));
-        if(!tmp)
+        av_reallocp(&program->stream_index, sizeof(unsigned int) * 
(program->nb_stream_indexes + 1));
+        if (!program->stream_index)
             return;
-        program->stream_index = tmp;
         program->stream_index[program->nb_stream_indexes++] = idx;
         return;
     }
-- 
1.7.10.4

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

Reply via email to