chiark / gitweb /
Stop dopalt() reading off the end of the character bitmap
authorBen Harris <bjh21@bjh21.me.uk>
Sat, 26 Oct 2024 18:00:39 +0000 (19:00 +0100)
committerBen Harris <bjh21@bjh21.me.uk>
Sat, 26 Oct 2024 18:00:39 +0000 (19:00 +0100)
Spotted by GCC -Warray-bounds.

bedstead.c

index db7caed40946b17c77ce2749a13bb0c1b799c150..089cc0f35d74b118d9853b9092ea266fe436d9a9 100644 (file)
@@ -2618,7 +2618,7 @@ static struct glyph const *glyphs_by_name[NGLYPHS];
 static void dolookups(struct glyph const *);
 
 static bool
-getpix(char const data[YSIZE], int x, int y, unsigned flags)
+getpix(char const data[YSIZE - 1], int x, int y, unsigned flags)
 {
 
        /*
@@ -3093,7 +3093,7 @@ dopalt(struct glyph const *g)
         * one pixel, and a right side-bearing of zero.  Space
         * characters get an advance width of three pixels.
         */
-       for (i = 0; i < YSIZE; i++)
+       for (i = 0; i < YSIZE - 1; i++)
                cols |= g->data[i] & ((1 << XSIZE) - 1);
        if (cols == 0)
                dh = 3 - XSIZE;