Commit 72eddc10 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit 'd872fb0f'

* commit 'd872fb0f':
  lavf: Reset the entry count and allocation size variables on av_reallocp failures

Conflicts:
	libavformat/avienc.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 328a5b93 d872fb0f
...@@ -694,9 +694,10 @@ static int avi_read_header(AVFormatContext *s) ...@@ -694,9 +694,10 @@ static int avi_read_header(AVFormatContext *s)
st->codec->extradata_size += 9; st->codec->extradata_size += 9;
if ((ret = av_reallocp(&st->codec->extradata, if ((ret = av_reallocp(&st->codec->extradata,
st->codec->extradata_size + st->codec->extradata_size +
FF_INPUT_BUFFER_PADDING_SIZE)) < 0) FF_INPUT_BUFFER_PADDING_SIZE)) < 0) {
st->codec->extradata_size = 0;
return ret; return ret;
else } else
memcpy(st->codec->extradata + st->codec->extradata_size - 9, memcpy(st->codec->extradata + st->codec->extradata_size - 9,
"BottomUp", 9); "BottomUp", 9);
} }
......
...@@ -567,8 +567,11 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -567,8 +567,11 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
int id = idx->entry % AVI_INDEX_CLUSTER_SIZE; int id = idx->entry % AVI_INDEX_CLUSTER_SIZE;
if (idx->ents_allocated <= idx->entry) { if (idx->ents_allocated <= idx->entry) {
idx->cluster = av_realloc_f(idx->cluster, sizeof(void*), cl+1); idx->cluster = av_realloc_f(idx->cluster, sizeof(void*), cl+1);
if (!idx->cluster) if (!idx->cluster) {
idx->ents_allocated = 0;
idx->entry = 0;
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
}
idx->cluster[cl] = av_malloc(AVI_INDEX_CLUSTER_SIZE*sizeof(AVIIentry)); idx->cluster[cl] = av_malloc(AVI_INDEX_CLUSTER_SIZE*sizeof(AVIIentry));
if (!idx->cluster[cl]) if (!idx->cluster[cl])
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
......
...@@ -950,8 +950,11 @@ static int dyn_buf_write(void *opaque, uint8_t *buf, int buf_size) ...@@ -950,8 +950,11 @@ static int dyn_buf_write(void *opaque, uint8_t *buf, int buf_size)
if (new_allocated_size > d->allocated_size) { if (new_allocated_size > d->allocated_size) {
int err; int err;
if ((err = av_reallocp(&d->buffer, new_allocated_size)) < 0) if ((err = av_reallocp(&d->buffer, new_allocated_size)) < 0) {
d->allocated_size = 0;
d->size = 0;
return err; return err;
}
d->allocated_size = new_allocated_size; d->allocated_size = new_allocated_size;
} }
memcpy(d->buffer + d->pos, buf, buf_size); memcpy(d->buffer + d->pos, buf, buf_size);
......
...@@ -337,8 +337,10 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst) ...@@ -337,8 +337,10 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst)
if(!mms->header_parsed) { if(!mms->header_parsed) {
if ((err = av_reallocp(&mms->asf_header, if ((err = av_reallocp(&mms->asf_header,
mms->asf_header_size + mms->asf_header_size +
mms->remaining_in_len)) < 0) mms->remaining_in_len)) < 0) {
mms->asf_header_size = 0;
return err; return err;
}
memcpy(mms->asf_header + mms->asf_header_size, memcpy(mms->asf_header + mms->asf_header_size,
mms->read_in_ptr, mms->remaining_in_len); mms->read_in_ptr, mms->remaining_in_len);
mms->asf_header_size += mms->remaining_in_len; mms->asf_header_size += mms->remaining_in_len;
......
...@@ -124,8 +124,10 @@ theora_header (AVFormatContext * s, int idx) ...@@ -124,8 +124,10 @@ theora_header (AVFormatContext * s, int idx)
} }
if ((err = av_reallocp(&st->codec->extradata, if ((err = av_reallocp(&st->codec->extradata,
cds + FF_INPUT_BUFFER_PADDING_SIZE)) < 0) cds + FF_INPUT_BUFFER_PADDING_SIZE)) < 0) {
st->codec->extradata_size = 0;
return err; return err;
}
cdp = st->codec->extradata + st->codec->extradata_size; cdp = st->codec->extradata + st->codec->extradata_size;
*cdp++ = os->psize >> 8; *cdp++ = os->psize >> 8;
*cdp++ = os->psize & 0xff; *cdp++ = os->psize & 0xff;
......
...@@ -317,9 +317,12 @@ vorbis_header (AVFormatContext * s, int idx) ...@@ -317,9 +317,12 @@ vorbis_header (AVFormatContext * s, int idx)
} }
} }
} else { } else {
int ret; int ret = fixup_vorbis_headers(s, priv, &st->codec->extradata);
st->codec->extradata_size = if (ret < 0) {
fixup_vorbis_headers(s, priv, &st->codec->extradata); st->codec->extradata_size = 0;
return ret;
}
st->codec->extradata_size = ret;
if ((ret = avpriv_vorbis_parse_extradata(st->codec, &priv->vp))) { if ((ret = avpriv_vorbis_parse_extradata(st->codec, &priv->vp))) {
av_freep(&st->codec->extradata); av_freep(&st->codec->extradata);
st->codec->extradata_size = 0; st->codec->extradata_size = 0;
......
...@@ -423,8 +423,10 @@ rdt_parse_sdp_line (AVFormatContext *s, int st_index, ...@@ -423,8 +423,10 @@ rdt_parse_sdp_line (AVFormatContext *s, int st_index,
if (first == -1) first = n; if (first == -1) first = n;
if (rdt->nb_rmst < count) { if (rdt->nb_rmst < count) {
if ((err = av_reallocp(&rdt->rmst, if ((err = av_reallocp(&rdt->rmst,
count * sizeof(*rdt->rmst))) < 0) count * sizeof(*rdt->rmst))) < 0) {
rdt->nb_rmst = 0;
return err; return err;
}
memset(rdt->rmst + rdt->nb_rmst, 0, memset(rdt->rmst + rdt->nb_rmst, 0,
(count - rdt->nb_rmst) * sizeof(*rdt->rmst)); (count - rdt->nb_rmst) * sizeof(*rdt->rmst));
rdt->nb_rmst = count; rdt->nb_rmst = count;
......
...@@ -89,8 +89,11 @@ static int rtmp_http_write(URLContext *h, const uint8_t *buf, int size) ...@@ -89,8 +89,11 @@ static int rtmp_http_write(URLContext *h, const uint8_t *buf, int size)
if (rt->out_size + size > rt->out_capacity) { if (rt->out_size + size > rt->out_capacity) {
int err; int err;
rt->out_capacity = (rt->out_size + size) * 2; rt->out_capacity = (rt->out_size + size) * 2;
if ((err = av_reallocp(&rt->out_data, rt->out_capacity)) < 0) if ((err = av_reallocp(&rt->out_data, rt->out_capacity)) < 0) {
rt->out_size = 0;
rt->out_capacity = 0;
return err; return err;
}
} }
memcpy(rt->out_data + rt->out_size, buf, size); memcpy(rt->out_data + rt->out_size, buf, size);
......
...@@ -156,8 +156,11 @@ static int add_tracked_method(RTMPContext *rt, const char *name, int id) ...@@ -156,8 +156,11 @@ static int add_tracked_method(RTMPContext *rt, const char *name, int id)
if (rt->nb_tracked_methods + 1 > rt->tracked_methods_size) { if (rt->nb_tracked_methods + 1 > rt->tracked_methods_size) {
rt->tracked_methods_size = (rt->nb_tracked_methods + 1) * 2; rt->tracked_methods_size = (rt->nb_tracked_methods + 1) * 2;
if ((err = av_reallocp(&rt->tracked_methods, rt->tracked_methods_size * if ((err = av_reallocp(&rt->tracked_methods, rt->tracked_methods_size *
sizeof(*rt->tracked_methods))) < 0) sizeof(*rt->tracked_methods))) < 0) {
rt->nb_tracked_methods = 0;
rt->tracked_methods_size = 0;
return err; return err;
}
} }
rt->tracked_methods[rt->nb_tracked_methods].name = av_strdup(name); rt->tracked_methods[rt->nb_tracked_methods].name = av_strdup(name);
......
...@@ -174,8 +174,10 @@ static int qt_rtp_parse_packet(AVFormatContext *s, PayloadContext *qt, ...@@ -174,8 +174,10 @@ static int qt_rtp_parse_packet(AVFormatContext *s, PayloadContext *qt,
if (qt->pkt.size > 0 && qt->timestamp == *timestamp) { if (qt->pkt.size > 0 && qt->timestamp == *timestamp) {
int err; int err;
if ((err = av_reallocp(&qt->pkt.data, qt->pkt.size + alen + if ((err = av_reallocp(&qt->pkt.data, qt->pkt.size + alen +
FF_INPUT_BUFFER_PADDING_SIZE)) < 0) FF_INPUT_BUFFER_PADDING_SIZE)) < 0) {
qt->pkt.size = 0;
return err; return err;
}
} else { } else {
av_freep(&qt->pkt.data); av_freep(&qt->pkt.data);
av_init_packet(&qt->pkt); av_init_packet(&qt->pkt);
......
...@@ -324,8 +324,10 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -324,8 +324,10 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt)
frame_size -= size; frame_size -= size;
frame_size -= 4; frame_size -= 4;
smk->curstream++; smk->curstream++;
if ((err = av_reallocp(&smk->bufs[smk->curstream], size)) < 0) if ((err = av_reallocp(&smk->bufs[smk->curstream], size)) < 0) {
smk->buf_sizes[smk->curstream] = 0;
return err; return err;
}
smk->buf_sizes[smk->curstream] = size; smk->buf_sizes[smk->curstream] = size;
ret = avio_read(s->pb, smk->bufs[smk->curstream], size); ret = avio_read(s->pb, smk->bufs[smk->curstream], size);
if(ret != size) if(ret != size)
......
...@@ -458,8 +458,11 @@ static int add_fragment(OutputStream *os, const char *file, const char *infofile ...@@ -458,8 +458,11 @@ static int add_fragment(OutputStream *os, const char *file, const char *infofile
if (os->nb_fragments >= os->fragments_size) { if (os->nb_fragments >= os->fragments_size) {
os->fragments_size = (os->fragments_size + 1) * 2; os->fragments_size = (os->fragments_size + 1) * 2;
if ((err = av_reallocp(&os->fragments, sizeof(*os->fragments) * if ((err = av_reallocp(&os->fragments, sizeof(*os->fragments) *
os->fragments_size)) < 0) os->fragments_size)) < 0) {
os->fragments_size = 0;
os->nb_fragments = 0;
return err; return err;
}
} }
frag = av_mallocz(sizeof(*frag)); frag = av_mallocz(sizeof(*frag));
if (!frag) if (!frag)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment