From b154aed94d708619c31b0b443e314e671b9220f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Lov=C3=A9n?= Date: Sat, 22 Jan 2022 15:37:57 +0100 Subject: [PATCH] Don't draw lines outside of context --- src/libmittos/graphics/graphics.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libmittos/graphics/graphics.c b/src/libmittos/graphics/graphics.c index 128589e..0b2859b 100644 --- a/src/libmittos/graphics/graphics.c +++ b/src/libmittos/graphics/graphics.c @@ -35,7 +35,9 @@ void draw_line( int64_t diff = dx - dy; uint32_t *fb = (uint32_t *)ctx->buffer; while(1) { - fb[PXL(ctx, x, y)] = clr; + if(0 < x && x < ctx->width && + 0 < y && y < ctx->height) + fb[PXL(ctx, x, y)] = clr; if(x == x1 && y == y1) break; if((2*diff) > -dy) {