vo_vaapi: fix segfault in draw_osd

When video width is not a multiple of slice size, the last slice will overflow. Fix this by adjusting the width of the last slice to fit within the video.

Fixes issue #10436
This commit is contained in:
Gusar321 2023-07-21 14:03:20 +02:00 committed by sfan5
parent c9064b57c0
commit 800d9eaa42
1 changed files with 4 additions and 0 deletions

View File

@ -684,6 +684,10 @@ static void draw_osd(struct vo *vo)
int rw = mp_rect_w(*rc);
int rh = mp_rect_h(*rc);
// reduce width of last slice to prevent overflow
if (n == num_mod_rc - 1)
rw = w - rc->x0;
void *src = mp_image_pixel_ptr(osd, 0, rc->x0, rc->y0);
void *dst = vaimg.planes[0] + rc->y0 * vaimg.stride[0] + rc->x0 * 4;