avviddec: Fix memory leaks and assertions in error cases if we can't allocate a frame

This commit is contained in:
Sebastian Dröge 2012-12-04 20:44:58 +01:00
parent f5c112990f
commit 47647e1cac

View file

@ -482,7 +482,7 @@ static int
gst_ffmpegviddec_get_buffer (AVCodecContext * context, AVFrame * picture) gst_ffmpegviddec_get_buffer (AVCodecContext * context, AVFrame * picture)
{ {
GstVideoCodecFrame *frame; GstVideoCodecFrame *frame;
GstFFMpegVidDecVideoFrame *dframe; GstFFMpegVidDecVideoFrame *dframe = NULL;
GstFFMpegVidDec *ffmpegdec; GstFFMpegVidDec *ffmpegdec;
gint c; gint c;
GstVideoInfo *info; GstVideoInfo *info;
@ -580,6 +580,10 @@ invalid_frame:
} }
fallback: fallback:
{ {
if (dframe)
gst_ffmpegviddec_video_frame_free (dframe);
picture->opaque = NULL;
return avcodec_default_get_buffer (context, picture); return avcodec_default_get_buffer (context, picture);
} }
duplicate_frame: duplicate_frame:
@ -666,6 +670,7 @@ gst_ffmpegviddec_release_buffer (AVCodecContext * context, AVFrame * picture)
/* we remove the opaque data now */ /* we remove the opaque data now */
picture->opaque = NULL; picture->opaque = NULL;
if (frame)
gst_ffmpegviddec_video_frame_free (frame); gst_ffmpegviddec_video_frame_free (frame);
/* zero out the reference in ffmpeg */ /* zero out the reference in ffmpeg */