From 04c6040fb93b4c918f6f561451419d2b89e42270 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Thu, 13 Sep 2018 07:34:35 +0200 Subject: [PATCH] Check screen bounds --- testSDL.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/testSDL.c b/testSDL.c index 8f1960c..e0455f1 100644 --- a/testSDL.c +++ b/testSDL.c @@ -855,6 +855,10 @@ void drawSpriteSquare(const unsigned char *sprite, int16_t x, int16_t y, Unit de */ void pixelFunc(PixelInfo *pixel) { + if (pixel->position.x < 0 || pixel->position.x >= SCREEN_WIDTH || + pixel->position.y < 0 || pixel->position.y >= SCREEN_HEIGHT) + printf("error: writing outside screen! %d %d\n",pixel->position.x,pixel->position.y); + if (pixel->position.y == MIDDLE_ROW) zBuffer[pixel->position.x] = pixel->depth;