aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/4xm.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2009-01-27 21:06:19 +0000
committerMichael Niedermayer <michaelni@gmx.at>2009-01-27 21:06:19 +0000
commitcc988dd77f484ad4a928432b6d46713cb5f4ce24 (patch)
tree448bd68783b6cf6e3032342b71c86a9a1ff4a255 /libavformat/4xm.c
parent59afda9f61c8d3b23699e72939858ce25b4ed2a8 (diff)
downloadffmpeg-cc988dd77f484ad4a928432b6d46713cb5f4ce24.tar.gz
Fix memleak of header in error returns.
Originally committed as revision 16831 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/4xm.c')
-rw-r--r--libavformat/4xm.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/libavformat/4xm.c b/libavformat/4xm.c
index 30d240310c..acaa9f8517 100644
--- a/libavformat/4xm.c
+++ b/libavformat/4xm.c
@@ -121,8 +121,10 @@ static int fourxm_read_header(AVFormatContext *s,
header = av_malloc(header_size);
if (!header)
return AVERROR(ENOMEM);
- if (get_buffer(pb, header, header_size) != header_size)
+ if (get_buffer(pb, header, header_size) != header_size){
+ av_free(header);
return AVERROR(EIO);
+ }
/* take the lazy approach and search for any and all vtrk and strk chunks */
for (i = 0; i < header_size - 8; i++) {
@@ -142,8 +144,10 @@ static int fourxm_read_header(AVFormatContext *s,
/* allocate a new AVStream */
st = av_new_stream(s, 0);
- if (!st)
+ if (!st){
+ av_free(header);
return AVERROR(ENOMEM);
+ }
av_set_pts_info(st, 60, 1, fourxm->fps);
fourxm->video_stream_index = st->index;
@@ -166,8 +170,10 @@ static int fourxm_read_header(AVFormatContext *s,
current_track = AV_RL32(&header[i + 8]);
if (current_track + 1 > fourxm->track_count) {
fourxm->track_count = current_track + 1;
- if((unsigned)fourxm->track_count >= UINT_MAX / sizeof(AudioTrack))
+ if((unsigned)fourxm->track_count >= UINT_MAX / sizeof(AudioTrack)){
+ av_free(header);
return -1;
+ }
fourxm->tracks = av_realloc(fourxm->tracks,
fourxm->track_count * sizeof(AudioTrack));
if (!fourxm->tracks) {
@@ -183,8 +189,10 @@ static int fourxm_read_header(AVFormatContext *s,
/* allocate a new AVStream */
st = av_new_stream(s, current_track);
- if (!st)
+ if (!st){
+ av_free(header);
return AVERROR(ENOMEM);
+ }
av_set_pts_info(st, 60, 1, fourxm->tracks[current_track].sample_rate);