diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-03-02 20:39:38 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-03-02 20:39:38 +0100 |
commit | 4f0d4acc7017a751da7739b17644b1151310343b (patch) | |
tree | 90ab21333c25aa5e636fcaa38c6cfc902d4fcef0 | |
parent | 667bf156526ffba556f3dd906d63d1952866ea63 (diff) | |
download | ffmpeg-4f0d4acc7017a751da7739b17644b1151310343b.tar.gz |
libxvid: cleanup on error pathes
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavcodec/libxvid.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/libavcodec/libxvid.c b/libavcodec/libxvid.c index fac2e8c57f..05a12db58b 100644 --- a/libavcodec/libxvid.c +++ b/libavcodec/libxvid.c @@ -73,6 +73,8 @@ struct xvid_ff_pass1 { struct xvid_context *context; /**< Pointer to private context */ }; +static int xvid_encode_close(AVCodecContext *avctx); + /* * Xvid 2-Pass Kludge Section * @@ -477,7 +479,7 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx) { if( x->twopassbuffer == NULL || x->old_twopassbuffer == NULL ) { av_log(avctx, AV_LOG_ERROR, "Xvid: Cannot allocate 2-pass log buffers\n"); - return -1; + goto fail; } x->twopassbuffer[0] = x->old_twopassbuffer[0] = 0; @@ -492,21 +494,21 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx) { if( fd == -1 ) { av_log(avctx, AV_LOG_ERROR, "Xvid: Cannot write 2-pass pipe\n"); - return -1; + goto fail; } x->twopassfd = fd; if( avctx->stats_in == NULL ) { av_log(avctx, AV_LOG_ERROR, "Xvid: No 2-pass information loaded for second pass\n"); - return -1; + goto fail; } if( strlen(avctx->stats_in) > write(fd, avctx->stats_in, strlen(avctx->stats_in)) ) { av_log(avctx, AV_LOG_ERROR, "Xvid: Cannot write to 2-pass pipe\n"); - return -1; + goto fail; } rc2pass2.filename = x->twopassfile; @@ -606,13 +608,16 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx) { xerr = xvid_encore(NULL, XVID_ENC_CREATE, &xvid_enc_create, NULL); if( xerr ) { av_log(avctx, AV_LOG_ERROR, "Xvid: Could not create encoder reference\n"); - return -1; + goto fail; } x->encoder_handle = xvid_enc_create.handle; avctx->coded_frame = &x->encoded_picture; return 0; +fail: + xvid_encode_close(avctx); + return -1; } static int xvid_encode_frame(AVCodecContext *avctx, AVPacket *pkt, |