diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-12-03 20:30:33 +0100 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-12-05 13:27:38 +0100 |
commit | b886512ef2503fc585c302484be71475d3100480 (patch) | |
tree | a86810192d46f5c0fd692aaf8cce0b9dae863ebf /fftools/ffmpeg.c | |
parent | 2d0bfbd0fafe5e869919120758903801f91530fa (diff) | |
download | ffmpeg-b886512ef2503fc585c302484be71475d3100480.tar.gz |
fftools/ffmpeg: Avoid allocating+freeing frame, check allocations
Fixes a potential crash upon av_frame_alloc() failure.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'fftools/ffmpeg.c')
-rw-r--r-- | fftools/ffmpeg.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 47e6a8683e..b0b32a69f2 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1291,7 +1291,7 @@ static void do_video_out(OutputFile *of, int forced_keyframe = 0; double pts_time; - if (i < nb0_frames && ost->last_frame) { + if (i < nb0_frames && ost->last_frame->buf[0]) { in_picture = ost->last_frame; } else in_picture = next_picture; @@ -1419,13 +1419,10 @@ static void do_video_out(OutputFile *of, do_video_stats(ost, frame_size); } - if (!ost->last_frame) - ost->last_frame = av_frame_alloc(); av_frame_unref(ost->last_frame); - if (next_picture && ost->last_frame) - av_frame_ref(ost->last_frame, next_picture); - else - av_frame_free(&ost->last_frame); + if (next_picture) + if (av_frame_ref(ost->last_frame, next_picture) < 0) + goto error; return; error: |