summaryrefslogtreecommitdiff
path: root/libavformat/movenc.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-11-08 11:08:57 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-11-08 11:08:57 +0100
commit4342b346d273366438f10a1cc665d0c2db2af469 (patch)
treeedf53510d6260436275026379cee2acfb750127e /libavformat/movenc.c
parent0bdc5db520ba9126776dd12b6734150ebcc7c559 (diff)
parent8cb7b7b461b52898765b38e3eff68c0ce88347f3 (diff)
Merge commit '8cb7b7b461b52898765b38e3eff68c0ce88347f3'
* commit '8cb7b7b461b52898765b38e3eff68c0ce88347f3': movenc: Avoid leaking locally allocated data when returning on errors Conflicts: libavformat/movenc.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/movenc.c')
-rw-r--r--libavformat/movenc.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 1d91716a27..5fc8594ee9 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -3787,7 +3787,7 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
MOVTrack *trk = &mov->tracks[pkt->stream_index];
AVCodecContext *enc = trk->enc;
unsigned int samples_in_chunk = 0;
- int size = pkt->size;
+ int size = pkt->size, ret = 0;
uint8_t *reformatted_data = NULL;
if (trk->entry) {
@@ -3896,16 +3896,20 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
/* copy frame to create needed atoms */
trk->vos_len = size;
trk->vos_data = av_malloc(size);
- if (!trk->vos_data)
- return AVERROR(ENOMEM);
+ if (!trk->vos_data) {
+ ret = AVERROR(ENOMEM);
+ goto err;
+ }
memcpy(trk->vos_data, pkt->data, size);
}
if (trk->entry >= trk->cluster_capacity) {
unsigned new_capacity = 2 * (trk->entry + MOV_INDEX_CLUSTER_SIZE);
if (av_reallocp_array(&trk->cluster, new_capacity,
- sizeof(*trk->cluster)))
- return AVERROR(ENOMEM);
+ sizeof(*trk->cluster))) {
+ ret = AVERROR(ENOMEM);
+ goto err;
+ }
trk->cluster_capacity = new_capacity;
}
@@ -3972,9 +3976,12 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
if (trk->hint_track >= 0 && trk->hint_track < mov->nb_streams)
ff_mov_add_hinted_packet(s, pkt, trk->hint_track, trk->entry,
reformatted_data, size);
+
end:
+err:
+
av_free(reformatted_data);
- return 0;
+ return ret;
}
static int mov_write_single_packet(AVFormatContext *s, AVPacket *pkt)