From 4618f2ca478230138e585692b9a60b1838b84981 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sat, 7 Jun 2025 17:24:54 +0300 Subject: [PATCH] Check both input and output size. --- drawing.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drawing.cpp b/drawing.cpp index 335b2bc6..e90ce7ae 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -1903,8 +1903,8 @@ static void setspecialmonitorpos(struct vidbuffer *vb) static void vbcopy(struct vidbuffer *vbout, struct vidbuffer *vbin) { if (vbout->locked) { - for (int h = 0; h < vbout->height_allocated; h++) { - memcpy(vbout->bufmem + h * vbout->rowbytes, vbin->bufmem + h * vbin->rowbytes, vbout->width_allocated * vbout->pixbytes); + for (int h = 0; h < vbout->height_allocated && h < vbin->height_allocated; h++) { + memcpy(vbout->bufmem + h * vbout->rowbytes, vbin->bufmem + h * vbin->rowbytes, (vbin->width_allocated > vbout->width_allocated ? vbout->width_allocated : vbin->width_allocated) * vbout->pixbytes); } } } -- 2.47.3