From fbfcdd766466b217e198a9b518fb51e1fe777b08 Mon Sep 17 00:00:00 2001 From: Lephe Date: Mon, 15 Jun 2020 13:44:51 +0200 Subject: [PATCH] render-fx: fix VRAM overflows in gint_dhline() and gint_dvline() Similar to 610362f. --- src/render-fx/dline.c | 2 ++ src/render-fx/masks.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/render-fx/dline.c b/src/render-fx/dline.c index 90273fc..b3b4058 100644 --- a/src/render-fx/dline.c +++ b/src/render-fx/dline.c @@ -7,6 +7,7 @@ void gint_dhline(int x1, int x2, int y, color_t color) { if((uint)y >= 64) return; if(x1 > x2) swap(x1, x2); + if(x1 >= 128 || x2 < 0) return; /* Get the masks for the [x1, x2] range */ uint32_t m[4]; @@ -42,6 +43,7 @@ void gint_dvline(int y1, int y2, int x, color_t color) { if((uint)x >= 128) return; if(y1 > y2) swap(y1, y2); + if(y1 >= 64 || y2 < 0) return; uint32_t *base = gint_vram + (y1 << 2) + (x >> 5); uint32_t *lword = base + ((y2 - y1 + 1) << 2); diff --git a/src/render-fx/masks.c b/src/render-fx/masks.c index fcc228d..26a4fcf 100644 --- a/src/render-fx/masks.c +++ b/src/render-fx/masks.c @@ -4,7 +4,7 @@ void masks(int x1, int x2, uint32_t *masks) { if(x1 < 0) x1 = 0; - if(x2 < 0) x2 = 0; + if(x2 >= 128) x2 = 127; /* Indexes of the first and last non-empty longs */ size_t l1 = x1 >> 5;