You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-04 22:03:09 +02:00
avcodec/vp8: Maintain consistency of frame pointers
Right now it is possible for the pointer for the current frame to
be set in the context even when it could not be properly set up;
this does not influence the ordinary ref frames, but only
VP8Context.prev_frame. And since this code has been ported to the
ProgressFrame API in d48d7bc434
,
this leads to segfaults, because the ProgressFrame API is less
forgiving than the ThreadFrame API (waiting on an uninitialized
ProgressFrame segfaults, waiting on an uninitialized ThreadFrame
is a no-op (the code behaves as if frame-threading is not in use)).
Fix this by maintaining the consistency of the frame pointers
in the context (by setting them later).
Fixes: NULL pointer dereference
Fixes: 68192/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP8_fuzzer-6180311026171904
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
@ -541,9 +541,12 @@ static int vp7_fade_frame(VP8Context *s, int alpha, int beta)
|
|||||||
|
|
||||||
/* preserve the golden frame, write a new previous frame */
|
/* preserve the golden frame, write a new previous frame */
|
||||||
if (s->framep[VP8_FRAME_GOLDEN] == s->framep[VP8_FRAME_PREVIOUS]) {
|
if (s->framep[VP8_FRAME_GOLDEN] == s->framep[VP8_FRAME_PREVIOUS]) {
|
||||||
s->framep[VP8_FRAME_PREVIOUS] = vp8_find_free_buffer(s);
|
VP8Frame *prev_frame = vp8_find_free_buffer(s);
|
||||||
if ((ret = vp8_alloc_frame(s, s->framep[VP8_FRAME_PREVIOUS], 1)) < 0)
|
|
||||||
|
ret = vp8_alloc_frame(s, prev_frame, 1);
|
||||||
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
s->framep[VP8_FRAME_PREVIOUS] = prev_frame;
|
||||||
|
|
||||||
dst = s->framep[VP8_FRAME_PREVIOUS]->tf.f;
|
dst = s->framep[VP8_FRAME_PREVIOUS]->tf.f;
|
||||||
|
|
||||||
@ -2675,8 +2678,6 @@ int vp78_decode_frame(AVCodecContext *avctx, AVFrame *rframe, int *got_frame,
|
|||||||
&s->frames[i] != s->framep[VP8_FRAME_ALTREF])
|
&s->frames[i] != s->framep[VP8_FRAME_ALTREF])
|
||||||
vp8_release_frame(&s->frames[i]);
|
vp8_release_frame(&s->frames[i]);
|
||||||
|
|
||||||
curframe = s->framep[VP8_FRAME_CURRENT] = vp8_find_free_buffer(s);
|
|
||||||
|
|
||||||
if (!s->colorspace)
|
if (!s->colorspace)
|
||||||
avctx->colorspace = AVCOL_SPC_BT470BG;
|
avctx->colorspace = AVCOL_SPC_BT470BG;
|
||||||
if (s->fullrange)
|
if (s->fullrange)
|
||||||
@ -2697,8 +2698,10 @@ int vp78_decode_frame(AVCodecContext *avctx, AVFrame *rframe, int *got_frame,
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
curframe = vp8_find_free_buffer(s);
|
||||||
if ((ret = vp8_alloc_frame(s, curframe, referenced)) < 0)
|
if ((ret = vp8_alloc_frame(s, curframe, referenced)) < 0)
|
||||||
goto err;
|
goto err;
|
||||||
|
s->framep[VP8_FRAME_CURRENT] = curframe;
|
||||||
if (s->keyframe)
|
if (s->keyframe)
|
||||||
curframe->tf.f->flags |= AV_FRAME_FLAG_KEY;
|
curframe->tf.f->flags |= AV_FRAME_FLAG_KEY;
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user