summaryrefslogtreecommitdiff
path: root/libavformat/avienc.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2016-05-22 01:54:50 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2016-05-22 02:14:33 +0200
commit9d5894b2399e3b2ce9fe8ddb5a28db66affefe25 (patch)
treedb6b0d443a49420f698ca6fdf3e6610128d1d1a9 /libavformat/avienc.c
parentea88dc3e8e2c079cf4bf5c31ac05c0e5a025c03a (diff)
downloadffmpeg-9d5894b2399e3b2ce9fe8ddb5a28db66affefe25.tar.gz
avformat/avienc: Fix memleaks on errors
Fixes CID1361951 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavformat/avienc.c')
-rw-r--r--libavformat/avienc.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/libavformat/avienc.c b/libavformat/avienc.c
index 2c748efb2d..9504a022f0 100644
--- a/libavformat/avienc.c
+++ b/libavformat/avienc.c
@@ -728,10 +728,10 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
} else
reshuffle_ret = 0;
if (par->format == AV_PIX_FMT_PAL8) {
- int ret2 = ff_get_packet_palette(s, opkt, reshuffle_ret, avist->palette);
- if (ret2 < 0)
- return ret2;
- if (ret2) {
+ ret = ff_get_packet_palette(s, opkt, reshuffle_ret, avist->palette);
+ if (ret < 0)
+ goto fail;
+ if (ret) {
int pal_size = 1 << par->bits_per_coded_sample;
int pc_tag, i;
@@ -763,7 +763,7 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
ret = avi_add_ientry(s, stream_index, tag, AVIIF_NO_TIME,
pal_size * 4 + 4);
if (ret < 0)
- return ret;
+ goto fail;
}
pc_tag = ff_start_tag(pb, tag);
avio_w8(pb, 0);
@@ -780,7 +780,10 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
}
if (reshuffle_ret) {
ret = avi_write_packet_internal(s, pkt);
- av_packet_free(&pkt);
+
+fail:
+ if (reshuffle_ret)
+ av_packet_free(&pkt);
return ret;
}
}