aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukasz Marek <lukasz.m.luki2@gmail.com>2014-11-22 22:30:28 +0100
committerLukasz Marek <lukasz.m.luki2@gmail.com>2014-11-23 03:33:00 +0100
commitbceabbdabab3e75b4dbccfafcd1758f40897a29a (patch)
tree12fad38454a57ce804816f30e98e925121d47ded
parent969382162f1884da758934cb86fc4a2c948635dd (diff)
downloadffmpeg-bceabbdabab3e75b4dbccfafcd1758f40897a29a.tar.gz
lavc/libvorbisdec: fix mem leak in case of init failure
Signed-off-by: Lukasz Marek <lukasz.m.luki2@gmail.com>
-rw-r--r--libavcodec/libvorbisdec.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/libavcodec/libvorbisdec.c b/libavcodec/libvorbisdec.c
index b703b65532..f2c5046cb4 100644
--- a/libavcodec/libvorbisdec.c
+++ b/libavcodec/libvorbisdec.c
@@ -35,17 +35,17 @@ typedef struct OggVorbisDecContext {
static int oggvorbis_decode_init(AVCodecContext *avccontext) {
OggVorbisDecContext *context = avccontext->priv_data ;
uint8_t *p= avccontext->extradata;
- int i, hsizes[3];
+ int i, hsizes[3], ret;
unsigned char *headers[3], *extradata = avccontext->extradata;
- vorbis_info_init(&context->vi) ;
- vorbis_comment_init(&context->vc) ;
-
if(! avccontext->extradata_size || ! p) {
av_log(avccontext, AV_LOG_ERROR, "vorbis extradata absent\n");
return -1;
}
+ vorbis_info_init(&context->vi) ;
+ vorbis_comment_init(&context->vc) ;
+
if(p[0] == 0 && p[1] == 30) {
for(i = 0; i < 3; i++){
hsizes[i] = bytestream_get_be16((const uint8_t **)&p);
@@ -65,7 +65,8 @@ static int oggvorbis_decode_init(AVCodecContext *avccontext) {
if(offset >= avccontext->extradata_size - 1) {
av_log(avccontext, AV_LOG_ERROR,
"vorbis header sizes damaged\n");
- return -1;
+ ret = -1;
+ goto error;
}
hsizes[i] += *p;
offset++;
@@ -83,7 +84,8 @@ static int oggvorbis_decode_init(AVCodecContext *avccontext) {
} else {
av_log(avccontext, AV_LOG_ERROR,
"vorbis initial header len is wrong: %d\n", *p);
- return -1;
+ ret = -1;
+ goto error;
}
for(i=0; i<3; i++){
@@ -92,7 +94,8 @@ static int oggvorbis_decode_init(AVCodecContext *avccontext) {
context->op.packet = headers[i];
if(vorbis_synthesis_headerin(&context->vi, &context->vc, &context->op)<0){
av_log(avccontext, AV_LOG_ERROR, "%d. vorbis header damaged\n", i+1);
- return -1;
+ ret = -1;
+ goto error;
}
}
@@ -105,6 +108,11 @@ static int oggvorbis_decode_init(AVCodecContext *avccontext) {
vorbis_block_init(&context->vd, &context->vb);
return 0 ;
+
+ error:
+ vorbis_info_clear(&context->vi);
+ vorbis_comment_clear(&context->vc) ;
+ return ret;
}