History

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 d48d7bc434f30dfbdf346f16715e4f2044b3e000, 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

Andreas Rheinhardt committed 2 years ago

Commit 494061a1 parent 9e1162b1 file · +7 −4Browse files

Unified · Split

libavcodec/vp8.c+7−4
@@ -541,9 +541,12 @@ static int vp7_fade_frame(VP8Context *s, int alpha, int beta) · 540 unmodified lines
541 541
542 /* preserve the golden frame, write a new previous frame */542 /* preserve the golden frame, write a new previous frame */
543 if (s->framep[VP8_FRAME_GOLDEN] == s->framep[VP8_FRAME_PREVIOUS]) {543 if (s->framep[VP8_FRAME_GOLDEN] == s->framep[VP8_FRAME_PREVIOUS]) {
544 s->framep[VP8_FRAME_PREVIOUS] = vp8_find_free_buffer(s);544 VP8Frame *prev_frame = vp8_find_free_buffer(s);
545 if ((ret = vp8_alloc_frame(s, s->framep[VP8_FRAME_PREVIOUS], 1)) < 0)545
546 ret = vp8_alloc_frame(s, prev_frame, 1);
547 if (ret < 0)
546 return ret;548 return ret;
549 s->framep[VP8_FRAME_PREVIOUS] = prev_frame;
547 550
548 dst = s->framep[VP8_FRAME_PREVIOUS]->tf.f;551 dst = s->framep[VP8_FRAME_PREVIOUS]->tf.f;
549 552
@@ -2675,8 +2678,6 @@ int vp78_decode_frame(AVCodecContext *avctx, AVFrame *rframe, int *got_frame, · 2125 unmodified lines
2675 &s->frames[i] != s->framep[VP8_FRAME_ALTREF])2678 &s->frames[i] != s->framep[VP8_FRAME_ALTREF])
2676 vp8_release_frame(&s->frames[i]);2679 vp8_release_frame(&s->frames[i]);
2677 2680
2678 curframe = s->framep[VP8_FRAME_CURRENT] = vp8_find_free_buffer(s);
2679
2680 if (!s->colorspace)2681 if (!s->colorspace)
2681 avctx->colorspace = AVCOL_SPC_BT470BG;2682 avctx->colorspace = AVCOL_SPC_BT470BG;
2682 if (s->fullrange)2683 if (s->fullrange)
@@ -2697,8 +2698,10 @@ int vp78_decode_frame(AVCodecContext *avctx, AVFrame *rframe, int *got_frame, · 14 unmodified lines
2697 goto err;2698 goto err;
2698 }2699 }
2699 2700
2701 curframe = vp8_find_free_buffer(s);
2700 if ((ret = vp8_alloc_frame(s, curframe, referenced)) < 0)2702 if ((ret = vp8_alloc_frame(s, curframe, referenced)) < 0)
2701 goto err;2703 goto err;
2704 s->framep[VP8_FRAME_CURRENT] = curframe;
2702 if (s->keyframe)2705 if (s->keyframe)
2703 curframe->tf.f->flags |= AV_FRAME_FLAG_KEY;2706 curframe->tf.f->flags |= AV_FRAME_FLAG_KEY;
2704 else2707 else

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