* commit '5626f994f273af80fb100d4743b963304de9e05c':
avformat: Use av_reallocp() where suitable
Conflicts:
libavformat/avidec.c
libavformat/avienc.c
libavformat/aviobuf.c
libavformat/oggparsevorbis.c
libavformat/utils.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
... | ... |
@@ -692,11 +692,11 @@ static int avi_read_header(AVFormatContext *s) |
692 | 692 |
if (st->codec->codec_tag == 0 && st->codec->height > 0 && |
693 | 693 |
st->codec->extradata_size < 1U << 30) { |
694 | 694 |
st->codec->extradata_size += 9; |
695 |
- st->codec->extradata = av_realloc_f(st->codec->extradata, |
|
696 |
- 1, |
|
697 |
- st->codec->extradata_size + |
|
698 |
- FF_INPUT_BUFFER_PADDING_SIZE); |
|
699 |
- if (st->codec->extradata) |
|
695 |
+ if ((ret = av_reallocp(&st->codec->extradata, |
|
696 |
+ st->codec->extradata_size + |
|
697 |
+ FF_INPUT_BUFFER_PADDING_SIZE)) < 0) |
|
698 |
+ return ret; |
|
699 |
+ else |
|
700 | 700 |
memcpy(st->codec->extradata + st->codec->extradata_size - 9, |
701 | 701 |
"BottomUp", 9); |
702 | 702 |
} |
... | ... |
@@ -562,6 +562,7 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt) |
562 | 562 |
} |
563 | 563 |
|
564 | 564 |
if (s->pb->seekable) { |
565 |
+ int err; |
|
565 | 566 |
AVIIndex* idx = &avist->indexes; |
566 | 567 |
int cl = idx->entry / AVI_INDEX_CLUSTER_SIZE; |
567 | 568 |
int id = idx->entry % AVI_INDEX_CLUSTER_SIZE; |
... | ... |
@@ -949,9 +949,9 @@ static int dyn_buf_write(void *opaque, uint8_t *buf, int buf_size) |
949 | 949 |
} |
950 | 950 |
|
951 | 951 |
if (new_allocated_size > d->allocated_size) { |
952 |
- d->buffer = av_realloc_f(d->buffer, 1, new_allocated_size); |
|
953 |
- if(d->buffer == NULL) |
|
954 |
- return AVERROR(ENOMEM); |
|
952 |
+ int err; |
|
953 |
+ if ((err = av_reallocp(&d->buffer, new_allocated_size)) < 0) |
|
954 |
+ return err; |
|
955 | 955 |
d->allocated_size = new_allocated_size; |
956 | 956 |
} |
957 | 957 |
memcpy(d->buffer + d->pos, buf, buf_size); |
... | ... |
@@ -71,7 +71,7 @@ static int bmv_read_header(AVFormatContext *s) |
71 | 71 |
static int bmv_read_packet(AVFormatContext *s, AVPacket *pkt) |
72 | 72 |
{ |
73 | 73 |
BMVContext *c = s->priv_data; |
74 |
- int type; |
|
74 |
+ int type, err; |
|
75 | 75 |
void *tmp; |
76 | 76 |
|
77 | 77 |
while (c->get_next) { |
... | ... |
@@ -85,10 +85,8 @@ static int bmv_read_packet(AVFormatContext *s, AVPacket *pkt) |
85 | 85 |
c->size = avio_rl24(s->pb); |
86 | 86 |
if (!c->size) |
87 | 87 |
return AVERROR_INVALIDDATA; |
88 |
- tmp = av_realloc(c->packet, c->size + 1); |
|
89 |
- if (!tmp) |
|
90 |
- return AVERROR(ENOMEM); |
|
91 |
- c->packet = tmp; |
|
88 |
+ if ((err = av_reallocp(&c->packet, c->size + 1)) < 0) |
|
89 |
+ return err; |
|
92 | 90 |
c->packet[0] = type; |
93 | 91 |
if (avio_read(s->pb, c->packet + 1, c->size) != c->size) |
94 | 92 |
return AVERROR(EIO); |
... | ... |
@@ -56,7 +56,7 @@ static av_cold int concat_close(URLContext *h) |
56 | 56 |
|
57 | 57 |
static av_cold int concat_open(URLContext *h, const char *uri, int flags) |
58 | 58 |
{ |
59 |
- char *node_uri = NULL, *tmp_uri; |
|
59 |
+ char *node_uri = NULL; |
|
60 | 60 |
int err = 0; |
61 | 61 |
int64_t size; |
62 | 62 |
size_t len, i; |
... | ... |
@@ -85,11 +85,8 @@ static av_cold int concat_open(URLContext *h, const char *uri, int flags) |
85 | 85 |
for (i = 0; *uri; i++) { |
86 | 86 |
/* parsing uri */ |
87 | 87 |
len = strcspn(uri, AV_CAT_SEPARATOR); |
88 |
- if (!(tmp_uri = av_realloc(node_uri, len+1))) { |
|
89 |
- err = AVERROR(ENOMEM); |
|
88 |
+ if ((err = av_reallocp(&node_uri, len + 1)) < 0) |
|
90 | 89 |
break; |
91 |
- } else |
|
92 |
- node_uri = tmp_uri; |
|
93 | 90 |
av_strlcpy(node_uri, uri, len+1); |
94 | 91 |
uri += len + strspn(uri+len, AV_CAT_SEPARATOR); |
95 | 92 |
|
... | ... |
@@ -114,10 +111,9 @@ static av_cold int concat_open(URLContext *h, const char *uri, int flags) |
114 | 114 |
|
115 | 115 |
if (err < 0) |
116 | 116 |
concat_close(h); |
117 |
- else if (!(nodes = av_realloc(nodes, data->length * sizeof(*nodes)))) { |
|
117 |
+ else if ((err = av_reallocp(&nodes, data->length * sizeof(*nodes))) < 0) |
|
118 | 118 |
concat_close(h); |
119 |
- err = AVERROR(ENOMEM); |
|
120 |
- } else |
|
119 |
+ else |
|
121 | 120 |
data->nodes = nodes; |
122 | 121 |
return err; |
123 | 122 |
} |
... | ... |
@@ -331,16 +331,14 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst) |
331 | 331 |
|
332 | 332 |
// if we successfully read everything. |
333 | 333 |
if(packet_id_type == mmst->header_packet_id) { |
334 |
+ int err; |
|
334 | 335 |
packet_type = SC_PKT_ASF_HEADER; |
335 | 336 |
// Store the asf header |
336 | 337 |
if(!mms->header_parsed) { |
337 |
- void *p = av_realloc(mms->asf_header, |
|
338 |
- mms->asf_header_size + mms->remaining_in_len); |
|
339 |
- if (!p) { |
|
340 |
- av_freep(&mms->asf_header); |
|
341 |
- return AVERROR(ENOMEM); |
|
342 |
- } |
|
343 |
- mms->asf_header = p; |
|
338 |
+ if ((err = av_reallocp(&mms->asf_header, |
|
339 |
+ mms->asf_header_size + |
|
340 |
+ mms->remaining_in_len)) < 0) |
|
341 |
+ return err; |
|
344 | 342 |
memcpy(mms->asf_header + mms->asf_header_size, |
345 | 343 |
mms->read_in_ptr, mms->remaining_in_len); |
346 | 344 |
mms->asf_header_size += mms->remaining_in_len; |
... | ... |
@@ -981,6 +981,7 @@ static int mov_read_extradata(MOVContext *c, AVIOContext *pb, MOVAtom atom, |
981 | 981 |
AVStream *st; |
982 | 982 |
uint64_t size; |
983 | 983 |
uint8_t *buf; |
984 |
+ int err; |
|
984 | 985 |
|
985 | 986 |
if (c->fc->nb_streams < 1) // will happen with jp2 files |
986 | 987 |
return 0; |
... | ... |
@@ -992,11 +993,9 @@ static int mov_read_extradata(MOVContext *c, AVIOContext *pb, MOVAtom atom, |
992 | 992 |
size= (uint64_t)st->codec->extradata_size + atom.size + 8 + FF_INPUT_BUFFER_PADDING_SIZE; |
993 | 993 |
if (size > INT_MAX || (uint64_t)atom.size > INT_MAX) |
994 | 994 |
return AVERROR_INVALIDDATA; |
995 |
- buf= av_realloc(st->codec->extradata, size); |
|
996 |
- if (!buf) |
|
997 |
- return AVERROR(ENOMEM); |
|
998 |
- st->codec->extradata= buf; |
|
999 |
- buf+= st->codec->extradata_size; |
|
995 |
+ if ((err = av_reallocp(&st->codec->extradata, size)) < 0) |
|
996 |
+ return err; |
|
997 |
+ buf = st->codec->extradata + st->codec->extradata_size; |
|
1000 | 998 |
st->codec->extradata_size= size - FF_INPUT_BUFFER_PADDING_SIZE; |
1001 | 999 |
AV_WB32( buf , atom.size + 8); |
1002 | 1000 |
AV_WL32( buf + 4, atom.type); |
... | ... |
@@ -104,12 +104,9 @@ static void sample_queue_push(HintSampleQueue *queue, uint8_t *data, int size, |
104 | 104 |
if (size <= 14) |
105 | 105 |
return; |
106 | 106 |
if (!queue->samples || queue->len >= queue->size) { |
107 |
- HintSample *samples; |
|
108 | 107 |
queue->size += 10; |
109 |
- samples = av_realloc(queue->samples, sizeof(HintSample)*queue->size); |
|
110 |
- if (!samples) |
|
108 |
+ if (av_reallocp(&queue->samples, sizeof(*queue->samples) * queue->size) < 0) |
|
111 | 109 |
return; |
112 |
- queue->samples = samples; |
|
113 | 110 |
} |
114 | 111 |
queue->samples[queue->len].data = data; |
115 | 112 |
queue->samples[queue->len].size = size; |
... | ... |
@@ -42,7 +42,7 @@ theora_header (AVFormatContext * s, int idx) |
42 | 42 |
struct ogg_stream *os = ogg->streams + idx; |
43 | 43 |
AVStream *st = s->streams[idx]; |
44 | 44 |
struct theora_params *thp = os->private; |
45 |
- int cds = st->codec->extradata_size + os->psize + 2; |
|
45 |
+ int cds = st->codec->extradata_size + os->psize + 2, err; |
|
46 | 46 |
uint8_t *cdp; |
47 | 47 |
|
48 | 48 |
if(!(os->buf[os->pstart] & 0x80)) |
... | ... |
@@ -123,8 +123,9 @@ theora_header (AVFormatContext * s, int idx) |
123 | 123 |
return -1; |
124 | 124 |
} |
125 | 125 |
|
126 |
- st->codec->extradata = av_realloc (st->codec->extradata, |
|
127 |
- cds + FF_INPUT_BUFFER_PADDING_SIZE); |
|
126 |
+ if ((err = av_reallocp(&st->codec->extradata, |
|
127 |
+ cds + FF_INPUT_BUFFER_PADDING_SIZE)) < 0) |
|
128 |
+ return err; |
|
128 | 129 |
cdp = st->codec->extradata + st->codec->extradata_size; |
129 | 130 |
*cdp++ = os->psize >> 8; |
130 | 131 |
*cdp++ = os->psize & 0xff; |
... | ... |
@@ -194,7 +194,8 @@ static unsigned int |
194 | 194 |
fixup_vorbis_headers(AVFormatContext * as, struct oggvorbis_private *priv, |
195 | 195 |
uint8_t **buf) |
196 | 196 |
{ |
197 |
- int i,offset, len, buf_len; |
|
197 |
+ int i, offset, len, err; |
|
198 |
+ int buf_len; |
|
198 | 199 |
unsigned char *ptr; |
199 | 200 |
|
200 | 201 |
len = priv->len[0] + priv->len[1] + priv->len[2]; |
... | ... |
@@ -213,7 +214,8 @@ fixup_vorbis_headers(AVFormatContext * as, struct oggvorbis_private *priv, |
213 | 213 |
offset += priv->len[i]; |
214 | 214 |
av_freep(&priv->packet[i]); |
215 | 215 |
} |
216 |
- *buf = av_realloc(*buf, offset + FF_INPUT_BUFFER_PADDING_SIZE); |
|
216 |
+ if ((err = av_reallocp(buf, offset + FF_INPUT_BUFFER_PADDING_SIZE)) < 0) |
|
217 |
+ return err; |
|
217 | 218 |
return offset; |
218 | 219 |
} |
219 | 220 |
|
... | ... |
@@ -419,15 +419,14 @@ rdt_parse_sdp_line (AVFormatContext *s, int st_index, |
419 | 419 |
|
420 | 420 |
for (n = 0; n < s->nb_streams; n++) |
421 | 421 |
if (s->streams[n]->id == stream->id) { |
422 |
- int count = s->streams[n]->index + 1; |
|
422 |
+ int count = s->streams[n]->index + 1, err; |
|
423 | 423 |
if (first == -1) first = n; |
424 | 424 |
if (rdt->nb_rmst < count) { |
425 |
- RMStream **rmst= av_realloc(rdt->rmst, count*sizeof(*rmst)); |
|
426 |
- if (!rmst) |
|
427 |
- return AVERROR(ENOMEM); |
|
428 |
- memset(rmst + rdt->nb_rmst, 0, |
|
429 |
- (count - rdt->nb_rmst) * sizeof(*rmst)); |
|
430 |
- rdt->rmst = rmst; |
|
425 |
+ if ((err = av_reallocp(&rdt->rmst, |
|
426 |
+ count * sizeof(*rdt->rmst))) < 0) |
|
427 |
+ return err; |
|
428 |
+ memset(rdt->rmst + rdt->nb_rmst, 0, |
|
429 |
+ (count - rdt->nb_rmst) * sizeof(*rdt->rmst)); |
|
431 | 430 |
rdt->nb_rmst = count; |
432 | 431 |
} |
433 | 432 |
rdt->rmst[s->streams[n]->index] = ff_rm_alloc_rmstream(); |
... | ... |
@@ -85,14 +85,12 @@ static int rtmp_http_send_cmd(URLContext *h, const char *cmd) |
85 | 85 |
static int rtmp_http_write(URLContext *h, const uint8_t *buf, int size) |
86 | 86 |
{ |
87 | 87 |
RTMP_HTTPContext *rt = h->priv_data; |
88 |
- void *ptr; |
|
89 | 88 |
|
90 | 89 |
if (rt->out_size + size > rt->out_capacity) { |
90 |
+ int err; |
|
91 | 91 |
rt->out_capacity = (rt->out_size + size) * 2; |
92 |
- ptr = av_realloc(rt->out_data, rt->out_capacity); |
|
93 |
- if (!ptr) |
|
94 |
- return AVERROR(ENOMEM); |
|
95 |
- rt->out_data = ptr; |
|
92 |
+ if ((err = av_reallocp(&rt->out_data, rt->out_capacity)) < 0) |
|
93 |
+ return err; |
|
96 | 94 |
} |
97 | 95 |
|
98 | 96 |
memcpy(rt->out_data + rt->out_size, buf, size); |
... | ... |
@@ -150,15 +150,13 @@ static const uint8_t rtmp_server_key[] = { |
150 | 150 |
|
151 | 151 |
static int add_tracked_method(RTMPContext *rt, const char *name, int id) |
152 | 152 |
{ |
153 |
- void *ptr; |
|
153 |
+ int err; |
|
154 | 154 |
|
155 | 155 |
if (rt->nb_tracked_methods + 1 > rt->tracked_methods_size) { |
156 | 156 |
rt->tracked_methods_size = (rt->nb_tracked_methods + 1) * 2; |
157 |
- ptr = av_realloc(rt->tracked_methods, |
|
158 |
- rt->tracked_methods_size * sizeof(*rt->tracked_methods)); |
|
159 |
- if (!ptr) |
|
160 |
- return AVERROR(ENOMEM); |
|
161 |
- rt->tracked_methods = ptr; |
|
157 |
+ if ((err = av_reallocp(&rt->tracked_methods, rt->tracked_methods_size * |
|
158 |
+ sizeof(*rt->tracked_methods))) < 0) |
|
159 |
+ return err; |
|
162 | 160 |
} |
163 | 161 |
|
164 | 162 |
rt->tracked_methods[rt->nb_tracked_methods].name = av_strdup(name); |
... | ... |
@@ -2063,7 +2061,6 @@ static int handle_invoke(URLContext *s, RTMPPacket *pkt) |
2063 | 2063 |
static int handle_notify(URLContext *s, RTMPPacket *pkt) { |
2064 | 2064 |
RTMPContext *rt = s->priv_data; |
2065 | 2065 |
const uint8_t *p = NULL; |
2066 |
- uint8_t *cp = NULL; |
|
2067 | 2066 |
uint8_t commandbuffer[64]; |
2068 | 2067 |
char statusmsg[128]; |
2069 | 2068 |
int stringlen; |
... | ... |
@@ -2098,25 +2095,22 @@ static int handle_notify(URLContext *s, RTMPPacket *pkt) { |
2098 | 2098 |
old_flv_size = rt->flv_size; |
2099 | 2099 |
rt->flv_size += datatowritelength + 15; |
2100 | 2100 |
} else { |
2101 |
+ int err; |
|
2101 | 2102 |
old_flv_size = 0; |
2102 | 2103 |
rt->flv_size = datatowritelength + 15; |
2103 | 2104 |
rt->flv_off = 0; |
2105 |
+ if ((err = av_reallocp(&rt->flv_data, rt->flv_size)) < 0) |
|
2106 |
+ return err; |
|
2107 |
+ bytestream2_init_writer(&pbc, rt->flv_data, rt->flv_size); |
|
2108 |
+ bytestream2_skip_p(&pbc, old_flv_size); |
|
2109 |
+ bytestream2_put_byte(&pbc, pkt->type); |
|
2110 |
+ bytestream2_put_be24(&pbc, datatowritelength); |
|
2111 |
+ bytestream2_put_be24(&pbc, ts); |
|
2112 |
+ bytestream2_put_byte(&pbc, ts >> 24); |
|
2113 |
+ bytestream2_put_be24(&pbc, 0); |
|
2114 |
+ bytestream2_put_buffer(&pbc, datatowrite, datatowritelength); |
|
2115 |
+ bytestream2_put_be32(&pbc, 0); |
|
2104 | 2116 |
} |
2105 |
- |
|
2106 |
- cp = av_realloc(rt->flv_data, rt->flv_size); |
|
2107 |
- if (!cp) |
|
2108 |
- return AVERROR(ENOMEM); |
|
2109 |
- rt->flv_data = cp; |
|
2110 |
- bytestream2_init_writer(&pbc, cp, rt->flv_size); |
|
2111 |
- bytestream2_skip_p(&pbc, old_flv_size); |
|
2112 |
- bytestream2_put_byte(&pbc, pkt->type); |
|
2113 |
- bytestream2_put_be24(&pbc, datatowritelength); |
|
2114 |
- bytestream2_put_be24(&pbc, ts); |
|
2115 |
- bytestream2_put_byte(&pbc, ts >> 24); |
|
2116 |
- bytestream2_put_be24(&pbc, 0); |
|
2117 |
- bytestream2_put_buffer(&pbc, datatowrite, datatowritelength); |
|
2118 |
- bytestream2_put_be32(&pbc, 0); |
|
2119 |
- |
|
2120 | 2117 |
return 0; |
2121 | 2118 |
} |
2122 | 2119 |
|
... | ... |
@@ -2186,7 +2180,6 @@ static int get_packet(URLContext *s, int for_header) |
2186 | 2186 |
{ |
2187 | 2187 |
RTMPContext *rt = s->priv_data; |
2188 | 2188 |
int ret; |
2189 |
- uint8_t *p; |
|
2190 | 2189 |
const uint8_t *next; |
2191 | 2190 |
uint32_t size; |
2192 | 2191 |
uint32_t ts, cts, pts=0; |
... | ... |
@@ -2250,19 +2243,21 @@ static int get_packet(URLContext *s, int for_header) |
2250 | 2250 |
if (rpkt.type == RTMP_PT_VIDEO || rpkt.type == RTMP_PT_AUDIO || |
2251 | 2251 |
(rpkt.type == RTMP_PT_NOTIFY && |
2252 | 2252 |
ff_amf_match_string(rpkt.data, rpkt.size, "onMetaData"))) { |
2253 |
+ int err; |
|
2253 | 2254 |
ts = rpkt.timestamp; |
2254 | 2255 |
|
2255 | 2256 |
// generate packet header and put data into buffer for FLV demuxer |
2256 | 2257 |
rt->flv_off = 0; |
2257 | 2258 |
rt->flv_size = rpkt.size + 15; |
2258 |
- rt->flv_data = p = av_realloc(rt->flv_data, rt->flv_size); |
|
2259 |
- bytestream_put_byte(&p, rpkt.type); |
|
2260 |
- bytestream_put_be24(&p, rpkt.size); |
|
2261 |
- bytestream_put_be24(&p, ts); |
|
2262 |
- bytestream_put_byte(&p, ts >> 24); |
|
2263 |
- bytestream_put_be24(&p, 0); |
|
2264 |
- bytestream_put_buffer(&p, rpkt.data, rpkt.size); |
|
2265 |
- bytestream_put_be32(&p, 0); |
|
2259 |
+ if ((err = av_reallocp(&rt->flv_data, rt->flv_size)) < 0) |
|
2260 |
+ return err; |
|
2261 |
+ bytestream_put_byte(&rt->flv_data, rpkt.type); |
|
2262 |
+ bytestream_put_be24(&rt->flv_data, rpkt.size); |
|
2263 |
+ bytestream_put_be24(&rt->flv_data, ts); |
|
2264 |
+ bytestream_put_byte(&rt->flv_data, ts >> 24); |
|
2265 |
+ bytestream_put_be24(&rt->flv_data, 0); |
|
2266 |
+ bytestream_put_buffer(&rt->flv_data, rpkt.data, rpkt.size); |
|
2267 |
+ bytestream_put_be32(&rt->flv_data, 0); |
|
2266 | 2268 |
ff_rtmp_packet_destroy(&rpkt); |
2267 | 2269 |
return 0; |
2268 | 2270 |
} else if (rpkt.type == RTMP_PT_NOTIFY) { |
... | ... |
@@ -2274,10 +2269,13 @@ static int get_packet(URLContext *s, int for_header) |
2274 | 2274 |
} |
2275 | 2275 |
return 0; |
2276 | 2276 |
} else if (rpkt.type == RTMP_PT_METADATA) { |
2277 |
+ int err; |
|
2278 |
+ uint8_t *p; |
|
2277 | 2279 |
// we got raw FLV data, make it available for FLV demuxer |
2278 | 2280 |
rt->flv_off = 0; |
2279 | 2281 |
rt->flv_size = rpkt.size; |
2280 |
- rt->flv_data = av_realloc(rt->flv_data, rt->flv_size); |
|
2282 |
+ if ((err = av_reallocp(&rt->flv_data, rt->flv_size)) < 0) |
|
2283 |
+ return err; |
|
2281 | 2284 |
/* rewrite timestamps */ |
2282 | 2285 |
next = rpkt.data; |
2283 | 2286 |
ts = rpkt.timestamp; |
... | ... |
@@ -2550,9 +2548,11 @@ reconnect: |
2550 | 2550 |
} |
2551 | 2551 |
|
2552 | 2552 |
if (rt->is_input) { |
2553 |
+ int err; |
|
2553 | 2554 |
// generate FLV header for demuxer |
2554 | 2555 |
rt->flv_size = 13; |
2555 |
- rt->flv_data = av_realloc(rt->flv_data, rt->flv_size); |
|
2556 |
+ if ((err = av_reallocp(&rt->flv_data, rt->flv_size)) < 0) |
|
2557 |
+ return err; |
|
2556 | 2558 |
rt->flv_off = 0; |
2557 | 2559 |
memcpy(rt->flv_data, "FLV\1\5\0\0\0\011\0\0\0\0", rt->flv_size); |
2558 | 2560 |
} else { |
... | ... |
@@ -239,14 +239,11 @@ static int asfrtp_parse_packet(AVFormatContext *s, PayloadContext *asf, |
239 | 239 |
|
240 | 240 |
int cur_len = start_off + len_off - off; |
241 | 241 |
int prev_len = out_len; |
242 |
- void *newmem; |
|
243 | 242 |
out_len += cur_len; |
244 | 243 |
if (FFMIN(cur_len, len - off) < 0) |
245 | 244 |
return -1; |
246 |
- newmem = av_realloc(asf->buf, out_len); |
|
247 |
- if (!newmem) |
|
248 |
- return -1; |
|
249 |
- asf->buf = newmem; |
|
245 |
+ if ((res = av_reallocp(&asf->buf, out_len)) < 0) |
|
246 |
+ return res; |
|
250 | 247 |
memcpy(asf->buf + prev_len, buf + off, |
251 | 248 |
FFMIN(cur_len, len - off)); |
252 | 249 |
avio_skip(pb, cur_len); |
... | ... |
@@ -172,8 +172,10 @@ static int qt_rtp_parse_packet(AVFormatContext *s, PayloadContext *qt, |
172 | 172 |
switch (packing_scheme) { |
173 | 173 |
case 3: /* one data packet spread over 1 or multiple RTP packets */ |
174 | 174 |
if (qt->pkt.size > 0 && qt->timestamp == *timestamp) { |
175 |
- qt->pkt.data = av_realloc(qt->pkt.data, qt->pkt.size + alen + |
|
176 |
- FF_INPUT_BUFFER_PADDING_SIZE); |
|
175 |
+ int err; |
|
176 |
+ if ((err = av_reallocp(&qt->pkt.data, qt->pkt.size + alen + |
|
177 |
+ FF_INPUT_BUFFER_PADDING_SIZE)) < 0) |
|
178 |
+ return err; |
|
177 | 179 |
} else { |
178 | 180 |
av_freep(&qt->pkt.data); |
179 | 181 |
av_init_packet(&qt->pkt); |
... | ... |
@@ -181,8 +183,6 @@ static int qt_rtp_parse_packet(AVFormatContext *s, PayloadContext *qt, |
181 | 181 |
qt->pkt.size = 0; |
182 | 182 |
qt->timestamp = *timestamp; |
183 | 183 |
} |
184 |
- if (!qt->pkt.data) |
|
185 |
- return AVERROR(ENOMEM); |
|
186 | 184 |
memcpy(qt->pkt.data + qt->pkt.size, buf + avio_tell(&pb), alen); |
187 | 185 |
qt->pkt.size += alen; |
188 | 186 |
if (has_marker_bit) { |
... | ... |
@@ -314,7 +314,7 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt) |
314 | 314 |
for(i = 0; i < 7; i++) { |
315 | 315 |
if(flags & 1) { |
316 | 316 |
uint32_t size; |
317 |
- uint8_t *tmpbuf; |
|
317 |
+ int err; |
|
318 | 318 |
|
319 | 319 |
size = avio_rl32(s->pb) - 4; |
320 | 320 |
if (!size || size + 4L > frame_size) { |
... | ... |
@@ -324,10 +324,8 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt) |
324 | 324 |
frame_size -= size; |
325 | 325 |
frame_size -= 4; |
326 | 326 |
smk->curstream++; |
327 |
- tmpbuf = av_realloc(smk->bufs[smk->curstream], size); |
|
328 |
- if (!tmpbuf) |
|
329 |
- return AVERROR(ENOMEM); |
|
330 |
- smk->bufs[smk->curstream] = tmpbuf; |
|
327 |
+ if ((err = av_reallocp(&smk->bufs[smk->curstream], size)) < 0) |
|
328 |
+ return err; |
|
331 | 329 |
smk->buf_sizes[smk->curstream] = size; |
332 | 330 |
ret = avio_read(s->pb, smk->bufs[smk->curstream], size); |
333 | 331 |
if(ret != size) |
... | ... |
@@ -453,12 +453,13 @@ fail: |
453 | 453 |
|
454 | 454 |
static int add_fragment(OutputStream *os, const char *file, const char *infofile, int64_t start_time, int64_t duration, int64_t start_pos, int64_t size) |
455 | 455 |
{ |
456 |
+ int err; |
|
456 | 457 |
Fragment *frag; |
457 | 458 |
if (os->nb_fragments >= os->fragments_size) { |
458 | 459 |
os->fragments_size = (os->fragments_size + 1) * 2; |
459 |
- os->fragments = av_realloc(os->fragments, sizeof(*os->fragments)*os->fragments_size); |
|
460 |
- if (!os->fragments) |
|
461 |
- return AVERROR(ENOMEM); |
|
460 |
+ if ((err = av_reallocp(&os->fragments, sizeof(*os->fragments) * |
|
461 |
+ os->fragments_size)) < 0) |
|
462 |
+ return err; |
|
462 | 463 |
} |
463 | 464 |
frag = av_mallocz(sizeof(*frag)); |
464 | 465 |
if (!frag) |
... | ... |
@@ -355,12 +355,8 @@ int av_probe_input_buffer2(AVIOContext *pb, AVInputFormat **fmt, |
355 | 355 |
score = probe_size < max_probe_size ? AVPROBE_SCORE_RETRY : 0; |
356 | 356 |
|
357 | 357 |
/* read probe data */ |
358 |
- buftmp = av_realloc(buf, probe_size + AVPROBE_PADDING_SIZE); |
|
359 |
- if(!buftmp){ |
|
360 |
- av_free(buf); |
|
361 |
- return AVERROR(ENOMEM); |
|
362 |
- } |
|
363 |
- buf=buftmp; |
|
358 |
+ if ((ret = av_reallocp(&buf, probe_size + AVPROBE_PADDING_SIZE)) < 0) |
|
359 |
+ return ret; |
|
364 | 360 |
if ((ret = avio_read(pb, buf + buf_offset, probe_size - buf_offset)) < 0) { |
365 | 361 |
/* fail if error was not end of file, otherwise, lower score */ |
366 | 362 |
if (ret != AVERROR_EOF) { |