chiark / gitweb /
Add assertions that we don't overflow the "points" array
authorBen Harris <bjh21@bjh21.me.uk>
Sun, 16 Nov 2025 13:54:31 +0000 (13:54 +0000)
committerBen Harris <bjh21@bjh21.me.uk>
Tue, 13 Jan 2026 21:55:10 +0000 (21:55 +0000)
bedstead.c

index 172492bdcced4b08269e361e9090688836c92590..52afbb3ab0c317cede3e2472f657ddb7ed5d59dd 100644 (file)
@@ -4366,6 +4366,7 @@ moveto(int x, int y)
 {
        struct point *p = &points[nextpoint++];
 
+       assert(nextpoint <= MAXPOINTS);
        p->v.x = x; p->v.y = y;
        p->next = p->prev = NULL;
 }
@@ -4375,6 +4376,7 @@ lineto(int x, int y)
 {
        struct point *p = &points[nextpoint++];
 
+       assert(nextpoint <= MAXPOINTS);
        p->v.x = x; p->v.y = y;
        p->next = NULL;
        p->prev = p - 1;