From 61aab598a031c2ef4023cbcc60d31391f8479c0d Mon Sep 17 00:00:00 2001 From: neonloop Date: Fri, 25 Mar 2022 21:29:10 +0000 Subject: Fixes nearest scaler overrun (thanks shauninman) --- scale.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scale.c b/scale.c index 99d0189..2f21ddc 100644 --- a/scale.c +++ b/scale.c @@ -108,6 +108,7 @@ static void scale_nearest(unsigned w, unsigned h, size_t pitch, const void *src, int dy = -dst_h; unsigned lines = h; bool copy = false; + size_t cpy_w = dst_w * SCREEN_BPP; dst += dst_offs; @@ -118,7 +119,7 @@ static void scale_nearest(unsigned w, unsigned h, size_t pitch, const void *src, if (copy) { copy = false; - memcpy(dst, dst - SCREEN_PITCH, SCREEN_PITCH); + memcpy(dst, dst - SCREEN_PITCH, cpy_w); dst += SCREEN_PITCH; dy += h; } else if (dy < 0) { -- cgit v1.2.3