1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-04-10 23:58:06 -05:00

Fix an arithmetic error in the X font downloader cache.

If you're trying to arrange that an array size is large enough for
element n to exist, and you also want to round it up to the next
multiple of 0x100, you must set the size to (n + 0x100) & ~0xFF, and
not (n + 0xFF) & ~0xFF. Put another way, the number you have to round
up is not n, but the minimum size n+1 that causes array[n] to exist.
This commit is contained in:
Simon Tatham 2015-08-23 14:10:59 +01:00
parent dc16dd5aa4
commit 87040f6fd2

View File

@ -634,7 +634,7 @@ static void x11font_cairo_cache_glyph(x11font_individual *xfi, int glyphindex)
* principle that Unicode characters come in contiguous blocks
* often used together */
int old_nglyphs = xfi->nglyphs;
xfi->nglyphs = (glyphindex + 0xFF) & ~0xFF;
xfi->nglyphs = (glyphindex + 0x100) & ~0xFF;
xfi->glyphcache = sresize(xfi->glyphcache, xfi->nglyphs,
struct cairo_cached_glyph);