From 3aa8e4c2ac1da2384a59370b7bc9e6ec4e5ce7eb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Wed, 13 Jul 2016 15:50:44 +0000 Subject: [PATCH] [CHARMAP] Don't overrun FillGrid() when accessing the last elements. Rewrite the code using 'for' loops, in the same style as what is done elsewhere in the code. CID 1363552 CORE-11597 #resolve svn path=/trunk/; revision=71924 --- reactos/base/applications/charmap/map.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/reactos/base/applications/charmap/map.c b/reactos/base/applications/charmap/map.c index 383d98fcb2f..3ce259f4f8d 100644 --- a/reactos/base/applications/charmap/map.c +++ b/reactos/base/applications/charmap/map.c @@ -107,8 +107,9 @@ FillGrid(PMAP infoPtr, i = XCELLS * infoPtr->iYStart; added = 0; - x = y = 0; - while ((y <= YCELLS) && (x <= XCELLS)) + + for (y = 0; y < YCELLS; y++) + for (x = 0; x < XCELLS; x++) { ch = (WCHAR)infoPtr->ValidGlyphs[i]; @@ -131,14 +132,6 @@ FillGrid(PMAP infoPtr, i++; ch = (WCHAR)i; - - // move to the next cell - x++; - if (x > XCELLS - 1) - { - x = 0; - y++; - } } SelectObject(ps->hdc, hOldFont); -- 2.17.1