lavc/libvorbisdec: fix mem leak in case of init failure

Signed-off-by: Lukasz Marek <lukasz.m.luki2@gmail.com>
pull/93/merge
Lukasz Marek 10 years ago
parent 969382162f
commit bceabbdaba
  1. 22
      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;
}

Loading…
Cancel
Save