diff options
author | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2010-10-16 04:33:38 +0300 |
---|---|---|
committer | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2010-10-16 04:38:20 +0300 |
commit | 266e0341bafc90b199fa7674a5044ba85428f5bf (patch) | |
tree | 70668ec0e03c42e606375abe0b88dc8311c9fce6 | |
parent | c3b6850e81d32f4ab17b0fc77eb96279e8f6a033 (diff) | |
download | mpv-266e0341bafc90b199fa7674a5044ba85428f5bf.tar.bz2 mpv-266e0341bafc90b199fa7674a5044ba85428f5bf.tar.xz |
vd_ffmpeg: fix calloc/av_free mixup
avctx->palctrl was allocated with calloc() but freed with av_freep().
Free it with free() instead. Also change the main decoder context
allocation to use talloc.
-rw-r--r-- | libmpcodecs/vd_ffmpeg.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/libmpcodecs/vd_ffmpeg.c b/libmpcodecs/vd_ffmpeg.c index 6bee762ed2..89b7fb54c9 100644 --- a/libmpcodecs/vd_ffmpeg.c +++ b/libmpcodecs/vd_ffmpeg.c @@ -22,6 +22,7 @@ #include <time.h> #include <stdbool.h> +#include "talloc.h" #include "config.h" #include "mp_msg.h" #include "options.h" @@ -172,10 +173,7 @@ static int init(sh_video_t *sh){ avcodec_initialized=1; } - ctx = sh->context = malloc(sizeof(vd_ffmpeg_ctx)); - if (!ctx) - return 0; - memset(ctx, 0, sizeof(vd_ffmpeg_ctx)); + ctx = sh->context = talloc_zero(NULL, vd_ffmpeg_ctx); lavc_codec = (AVCodec *)avcodec_find_decoder_by_name(sh->codec->dll); if(!lavc_codec){ @@ -388,14 +386,13 @@ static void uninit(sh_video_t *sh){ mp_tmsg(MSGT_DECVIDEO, MSGL_ERR, "Could not close codec.\n"); av_freep(&avctx->extradata); - av_freep(&avctx->palctrl); + free(avctx->palctrl); av_freep(&avctx->slice_offset); } av_freep(&avctx); av_freep(&ctx->pic); - if (ctx) - free(ctx); + talloc_free(ctx); } static void draw_slice(struct AVCodecContext *s, |