---
libavformat/avienc.c | 7 +++----
libavformat/aviobuf.c | 6 +++---
libavformat/bmv.c | 8 +++-----
libavformat/concat.c | 13 +++++--------
libavformat/mmst.c | 12 ++++--------
libavformat/movenchint.c | 6 ++----
6 files changed, 20 insertions(+), 32 deletions(-)
diff --git a/libavformat/avienc.c b/libavformat/avienc.c
index 9d1f510..a4bd6f9 100644
--- a/libavformat/avienc.c
+++ b/libavformat/avienc.c
@@ -498,7 +498,7 @@ static int avi_write_packet(AVFormatContext *s, AVPacket
*pkt)
const int stream_index= pkt->stream_index;
AVIStream *avist= s->streams[stream_index]->priv_data;
AVCodecContext *enc= s->streams[stream_index]->codec;
- int size= pkt->size;
+ int size= pkt->size, err;
while(enc->block_align==0 && pkt->dts != AV_NOPTS_VALUE && pkt->dts >
avist->packet_count){
AVPacket empty_packet;
@@ -537,9 +537,8 @@ static int avi_write_packet(AVFormatContext *s, AVPacket
*pkt)
int cl = idx->entry / AVI_INDEX_CLUSTER_SIZE;
int id = idx->entry % AVI_INDEX_CLUSTER_SIZE;
if (idx->ents_allocated <= idx->entry) {
- idx->cluster = av_realloc(idx->cluster, (cl+1)*sizeof(void*));
- if (!idx->cluster)
- return -1;
+ if ((err = av_reallocp(&idx->cluster, (cl + 1) * sizeof(void*))) <
0)
+ return err;
idx->cluster[cl] =
av_malloc(AVI_INDEX_CLUSTER_SIZE*sizeof(AVIIentry));
if (!idx->cluster[cl])
return -1;
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index d2eaf36..dca8608 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -853,6 +853,7 @@ static int dyn_buf_write(void *opaque, uint8_t *buf, int
buf_size)
{
DynBuffer *d = opaque;
unsigned new_size, new_allocated_size;
+ int err;
/* reallocate buffer if needed */
new_size = d->pos + buf_size;
@@ -867,9 +868,8 @@ static int dyn_buf_write(void *opaque, uint8_t *buf, int
buf_size)
}
if (new_allocated_size > d->allocated_size) {
- d->buffer = av_realloc(d->buffer, new_allocated_size);
- if(d->buffer == NULL)
- return AVERROR(ENOMEM);
+ if ((err = av_reallocp(&d->buffer, new_allocated_size)) < 0)
+ return err;
d->allocated_size = new_allocated_size;
}
memcpy(d->buffer + d->pos, buf, buf_size);
diff --git a/libavformat/bmv.c b/libavformat/bmv.c
index ce157e8..f474648 100644
--- a/libavformat/bmv.c
+++ b/libavformat/bmv.c
@@ -71,7 +71,7 @@ static int bmv_read_header(AVFormatContext *s)
static int bmv_read_packet(AVFormatContext *s, AVPacket *pkt)
{
BMVContext *c = s->priv_data;
- int type;
+ int type, err;
void *tmp;
while (c->get_next) {
@@ -85,10 +85,8 @@ static int bmv_read_packet(AVFormatContext *s, AVPacket *pkt)
c->size = avio_rl24(s->pb);
if (!c->size)
return AVERROR_INVALIDDATA;
- tmp = av_realloc(c->packet, c->size + 1);
- if (!tmp)
- return AVERROR(ENOMEM);
- c->packet = tmp;
+ if ((err = av_reallocp(&c->packet, c->size + 1)) < 0)
+ return err;
c->packet[0] = type;
if (avio_read(s->pb, c->packet + 1, c->size) != c->size)
return AVERROR(EIO);
diff --git a/libavformat/concat.c b/libavformat/concat.c
index 24c50c1..3bc4526 100644
--- a/libavformat/concat.c
+++ b/libavformat/concat.c
@@ -56,7 +56,7 @@ static av_cold int concat_close(URLContext *h)
static av_cold int concat_open(URLContext *h, const char *uri, int flags)
{
- char *node_uri = NULL, *tmp_uri;
+ char *node_uri = NULL;
int err = 0;
int64_t size;
size_t len, i;
@@ -85,11 +85,9 @@ static av_cold int concat_open(URLContext *h, const char
*uri, int flags)
for (i = 0; *uri; i++) {
/* parsing uri */
len = strcspn(uri, AV_CAT_SEPARATOR);
- if (!(tmp_uri = av_realloc(node_uri, len+1))) {
- err = AVERROR(ENOMEM);
+ if ((err = av_reallocp(&node_uri, len + 1)) < 0)
break;
- } else
- node_uri = tmp_uri;
+ else
av_strlcpy(node_uri, uri, len+1);
uri += len + strspn(uri+len, AV_CAT_SEPARATOR);
@@ -114,10 +112,9 @@ static av_cold int concat_open(URLContext *h, const char
*uri, int flags)
if (err < 0)
concat_close(h);
- else if (!(nodes = av_realloc(nodes, data->length * sizeof(*nodes)))) {
+ else if ((err = av_reallocp(&nodes, data->length * sizeof(*nodes))) < 0)
concat_close(h);
- err = AVERROR(ENOMEM);
- } else
+ else
data->nodes = nodes;
return err;
}
diff --git a/libavformat/mmst.c b/libavformat/mmst.c
index 4b96f5d..39d4e63 100644
--- a/libavformat/mmst.c
+++ b/libavformat/mmst.c
@@ -300,7 +300,7 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext
*mmst)
} else {
int length_remaining;
int packet_id_type;
- int tmp;
+ int tmp, err;
// note we cache the first 8 bytes,
// then fill up the buffer with the others
@@ -334,13 +334,9 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext
*mmst)
packet_type = SC_PKT_ASF_HEADER;
// Store the asf header
if(!mms->header_parsed) {
- void *p = av_realloc(mms->asf_header,
- mms->asf_header_size +
mms->remaining_in_len);
- if (!p) {
- av_freep(&mms->asf_header);
- return AVERROR(ENOMEM);
- }
- mms->asf_header = p;
+ if ((err = av_reallocp(&mms->asf_header,
mms->asf_header_size +
+ mms->remaining_in_len)) < 0)
+ return err;
memcpy(mms->asf_header + mms->asf_header_size,
mms->read_in_ptr, mms->remaining_in_len);
mms->asf_header_size += mms->remaining_in_len;
diff --git a/libavformat/movenchint.c b/libavformat/movenchint.c
index 05a43cf..dbbe22c 100644
--- a/libavformat/movenchint.c
+++ b/libavformat/movenchint.c
@@ -104,12 +104,10 @@ static void sample_queue_push(HintSampleQueue *queue,
uint8_t *data, int size,
if (size <= 14)
return;
if (!queue->samples || queue->len >= queue->size) {
- HintSample *samples;
queue->size += 10;
- samples = av_realloc(queue->samples, sizeof(HintSample)*queue->size);
- if (!samples)
+ av_reallocp(&queue->samples, sizeof(HintSample) * queue->size);
+ if (!queue->samples)
return;
- queue->samples = samples;
}
queue->samples[queue->len].data = data;
queue->samples[queue->len].size = size;
--
1.7.10.4
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel