You've already forked FFmpeg
							
							
				mirror of
				https://github.com/FFmpeg/FFmpeg.git
				synced 2025-10-30 23:18:11 +02:00 
			
		
		
		
	avfilter: do not leak AVFrame on failed buffer allocation
Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
		| @@ -248,8 +248,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inbuf) | |||||||
|         outbuf = inbuf; |         outbuf = inbuf; | ||||||
|     } else { |     } else { | ||||||
|         outbuf = ff_get_audio_buffer(inlink, inbuf->nb_samples); |         outbuf = ff_get_audio_buffer(inlink, inbuf->nb_samples); | ||||||
|         if (!outbuf) |         if (!outbuf) { | ||||||
|  |             av_frame_free(&inbuf); | ||||||
|             return AVERROR(ENOMEM); |             return AVERROR(ENOMEM); | ||||||
|  |         } | ||||||
|         av_frame_copy_props(outbuf, inbuf); |         av_frame_copy_props(outbuf, inbuf); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -195,8 +195,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamplesref) | |||||||
|  |  | ||||||
|     outsamplesref = ff_get_audio_buffer(outlink, n_out); |     outsamplesref = ff_get_audio_buffer(outlink, n_out); | ||||||
|  |  | ||||||
|     if(!outsamplesref) |     if(!outsamplesref) { | ||||||
|  |         av_frame_free(&insamplesref); | ||||||
|         return AVERROR(ENOMEM); |         return AVERROR(ENOMEM); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     av_frame_copy_props(outsamplesref, insamplesref); |     av_frame_copy_props(outsamplesref, insamplesref); | ||||||
|     outsamplesref->format                = outlink->format; |     outsamplesref->format                = outlink->format; | ||||||
|   | |||||||
| @@ -1090,8 +1090,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *src_buffer) | |||||||
|     while (src < src_end) { |     while (src < src_end) { | ||||||
|         if (!atempo->dst_buffer) { |         if (!atempo->dst_buffer) { | ||||||
|             atempo->dst_buffer = ff_get_audio_buffer(outlink, n_out); |             atempo->dst_buffer = ff_get_audio_buffer(outlink, n_out); | ||||||
|             if (!atempo->dst_buffer) |             if (!atempo->dst_buffer) { | ||||||
|  |                 av_frame_free(&src_buffer); | ||||||
|                 return AVERROR(ENOMEM); |                 return AVERROR(ENOMEM); | ||||||
|  |             } | ||||||
|             av_frame_copy_props(atempo->dst_buffer, src_buffer); |             av_frame_copy_props(atempo->dst_buffer, src_buffer); | ||||||
|  |  | ||||||
|             atempo->dst = atempo->dst_buffer->data[0]; |             atempo->dst = atempo->dst_buffer->data[0]; | ||||||
|   | |||||||
| @@ -134,8 +134,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) | |||||||
|         out_frame = frame; |         out_frame = frame; | ||||||
|     } else { |     } else { | ||||||
|         out_frame = ff_get_audio_buffer(inlink, frame->nb_samples); |         out_frame = ff_get_audio_buffer(inlink, frame->nb_samples); | ||||||
|         if (!out_frame) |         if (!out_frame) { | ||||||
|  |             av_frame_free(&frame); | ||||||
|             return AVERROR(ENOMEM); |             return AVERROR(ENOMEM); | ||||||
|  |         } | ||||||
|         av_frame_copy(out_frame, frame); |         av_frame_copy(out_frame, frame); | ||||||
|         ret = av_frame_copy_props(out_frame, frame); |         ret = av_frame_copy_props(out_frame, frame); | ||||||
|         if (ret < 0) { |         if (ret < 0) { | ||||||
|   | |||||||
| @@ -383,8 +383,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) | |||||||
|     AVFrame *outsamples = ff_get_audio_buffer(outlink, n); |     AVFrame *outsamples = ff_get_audio_buffer(outlink, n); | ||||||
|     PanContext *pan = inlink->dst->priv; |     PanContext *pan = inlink->dst->priv; | ||||||
|  |  | ||||||
|     if (!outsamples) |     if (!outsamples) { | ||||||
|  |         av_frame_free(&insamples); | ||||||
|         return AVERROR(ENOMEM); |         return AVERROR(ENOMEM); | ||||||
|  |     } | ||||||
|     swr_convert(pan->swr, outsamples->extended_data, n, |     swr_convert(pan->swr, outsamples->extended_data, n, | ||||||
|                 (void *)insamples->extended_data, n); |                 (void *)insamples->extended_data, n); | ||||||
|     av_frame_copy_props(outsamples, insamples); |     av_frame_copy_props(outsamples, insamples); | ||||||
|   | |||||||
| @@ -411,8 +411,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf) | |||||||
|         out_buf = buf; |         out_buf = buf; | ||||||
|     } else { |     } else { | ||||||
|         out_buf = ff_get_audio_buffer(inlink, nb_samples); |         out_buf = ff_get_audio_buffer(inlink, nb_samples); | ||||||
|         if (!out_buf) |         if (!out_buf) { | ||||||
|  |             av_frame_free(&buf); | ||||||
|             return AVERROR(ENOMEM); |             return AVERROR(ENOMEM); | ||||||
|  |         } | ||||||
|         ret = av_frame_copy_props(out_buf, buf); |         ret = av_frame_copy_props(out_buf, buf); | ||||||
|         if (ret < 0) { |         if (ret < 0) { | ||||||
|             av_frame_free(&out_buf); |             av_frame_free(&out_buf); | ||||||
|   | |||||||
| @@ -259,8 +259,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) | |||||||
|     int i; |     int i; | ||||||
|  |  | ||||||
|     out = ff_get_video_buffer(outlink, inlink->w, inlink->h); |     out = ff_get_video_buffer(outlink, inlink->w, inlink->h); | ||||||
|     if (!out) |     if (!out) { | ||||||
|  |         av_frame_free(&in); | ||||||
|         return AVERROR(ENOMEM); |         return AVERROR(ENOMEM); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     av_frame_copy_props(out, in); |     av_frame_copy_props(out, in); | ||||||
|     desc = av_pix_fmt_desc_get(inlink->format); |     desc = av_pix_fmt_desc_get(inlink->format); | ||||||
|   | |||||||
| @@ -255,8 +255,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) | |||||||
|     int i, j, plane; |     int i, j, plane; | ||||||
|  |  | ||||||
|     out = ff_get_video_buffer(outlink, inlink->w, inlink->h); |     out = ff_get_video_buffer(outlink, inlink->w, inlink->h); | ||||||
|     if (!out) |     if (!out) { | ||||||
|  |         av_frame_free(&in); | ||||||
|         return AVERROR(ENOMEM); |         return AVERROR(ENOMEM); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     av_frame_copy_props(out, in); |     av_frame_copy_props(out, in); | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user