summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2009-09-23 15:16:36 +0000
committerMichael Niedermayer <michaelni@gmx.at>2009-09-23 15:16:36 +0000
commit2a9b5c9b429d4162f449771a5043310b3f4acc06 (patch)
tree738e1a196fde016311f5ab0aa4fd2fbc6aadc104 /libavcodec
parentaedc98b0a4ee434aa54908b815f78a4c563c1d31 (diff)
Make sure priv_data is freed and codec is set to NULL in case of failure of avcodec_open().
Originally committed as revision 20002 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/utils.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index c31608df99..4ab0c350ee 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -475,23 +475,20 @@ int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec)
if (((avctx->coded_width || avctx->coded_height)
&& avcodec_check_dimensions(avctx, avctx->coded_width, avctx->coded_height))
|| avctx->channels > SANE_NB_CHANNELS) {
- av_freep(&avctx->priv_data);
ret = AVERROR(EINVAL);
- goto end;
+ goto free_and_end;
}
avctx->codec = codec;
if(avctx->codec_id != codec->id || avctx->codec_type != codec->type){
av_log(avctx, AV_LOG_ERROR, "codec type or id mismatches\n");
- goto end;
+ goto free_and_end;
}
avctx->frame_number = 0;
if(avctx->codec->init){
ret = avctx->codec->init(avctx);
if (ret < 0) {
- av_freep(&avctx->priv_data);
- avctx->codec= NULL;
- goto end;
+ goto free_and_end;
}
}
ret=0;
@@ -503,6 +500,10 @@ end:
(*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_RELEASE);
}
return ret;
+free_and_end:
+ av_freep(&avctx->priv_data);
+ avctx->codec= NULL;
+ goto end;
}
int attribute_align_arg avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size,