render-cg: fix potential VRAM overflow in gint_dhline()

A missing coordinate check in gint_dhline() would allow lines entirely
out of bounds of the screen to write pixels outside of their expected
range, often wrapping up to the next line, but possibly overflowing from
VRAM.
This commit is contained in:
Lephe 2020-06-13 19:13:01 +02:00
parent caa4f675c9
commit 610362f8c9
No known key found for this signature in database
GPG key ID: 1BBA026E13FC0495

View file

@ -7,6 +7,7 @@ void gint_dhline(int x1, int x2, int y, uint16_t color)
/* Order and bounds */
if((uint)y >= 224) return;
if(x1 > x2) swap(x1, x2);
if(x1 >= 396 || x2 < 0) return;
if(x1 < 0) x1 = 0;
if(x2 >= 396) x2 = 395;