Skip to content

Commit

Permalink
vo_gpu: fix ra_fbo stack-use-after-scope
Browse files Browse the repository at this point in the history
281b1d8 introduced a stack use after
scope because dest_fbo can be reassigned a new pointer and then be used
by pass_draw_to_screen outside of that scope where the pointer is no
longer valid. Fix this by rearranging the variables so the assignment is
done in the same scope as the pass_draw_to_screen call instead.
  • Loading branch information
Dudemanguy committed Nov 28, 2023
1 parent 2bcdf59 commit 8f1f188
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions video/out/gpu/video.c
Expand Up @@ -3365,8 +3365,8 @@ void gl_video_render_frame(struct gl_video *p, struct vo_frame *frame,

// For the non-interpolation case, we draw to a single "cache"
// texture to speed up subsequent re-draws (if any exist)
const struct ra_fbo *dest_fbo = fbo;
bool repeats = frame->num_vsyncs > 1 && frame->display_synced;
bool r = false;
if ((repeats || frame->still) && !p->dumb_mode &&
(p->ra->caps & RA_CAP_BLIT) && fbo->tex->params.blit_dst)
{
Expand All @@ -3376,15 +3376,12 @@ void gl_video_render_frame(struct gl_video *p, struct vo_frame *frame,
const struct ra_format *fmt = fbo->tex->params.format;
if (fmt->dummy_format)
fmt = p->fbo_format;

bool r = ra_tex_resize(p->ra, p->log, &p->output_tex,
fbo->tex->params.w, fbo->tex->params.h,
fmt);
if (r) {
dest_fbo = &(struct ra_fbo) { p->output_tex };
p->output_tex_valid = true;
}
r = ra_tex_resize(p->ra, p->log, &p->output_tex,
fbo->tex->params.w, fbo->tex->params.h,
fmt);
}
const struct ra_fbo *dest_fbo = r ? &(struct ra_fbo) { p->output_tex } : fbo;
p->output_tex_valid = r;
pass_draw_to_screen(p, dest_fbo, flags);
}

Expand Down

0 comments on commit 8f1f188

Please sign in to comment.