History

avfilter/vf_transpose: fix un-checked potential memory allocation failure

Wu Jianhua committed 4 years ago

Commit ceeff7a1 parent 4f44a211 file · +12 −3Browse files

Unified · Split

libavfilter/vf_transpose.c+12−3
@@ -328,6 +328,7 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, · 327 unmodified lines
328328
329329 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
330330 {
331+ int err = 0;
331332 AVFilterContext *ctx = inlink->dst;
332333 TransContext *s = ctx->priv;
333334 AVFilterLink *outlink = ctx->outputs[0];
@@ -339,10 +340,13 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 5 unmodified lines
339340
340341 out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
341342 if (!out) {
342− av_frame_free(&in);
343− return AVERROR(ENOMEM);
343+ err = AVERROR(ENOMEM);
344+ goto fail;
344345 }
345− av_frame_copy_props(out, in);
346+
347+ err = av_frame_copy_props(out, in);
348+ if (err < 0)
349+ goto fail;
346350
347351 if (in->sample_aspect_ratio.num == 0) {
348352 out->sample_aspect_ratio = in->sample_aspect_ratio;
@@ -356,6 +360,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 7 unmodified lines
356360 FFMIN(outlink->h, ff_filter_get_nb_threads(ctx)));
357361 av_frame_free(&in);
358362 return ff_filter_frame(outlink, out);
363+
364+fail:
365+ av_frame_free(&in);
366+ av_frame_free(&out);
367+ return err;
359368 }
360369
361370 #define OFFSET(x) offsetof(TransContext, x)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t