ProcRenderAddGlyphs: Convert while loops to for loops where more natural

This commit is contained in:
Carl Worth 2007-07-25 14:57:13 -07:00
parent f3955c0a02
commit dc8a528cd6

View File

@ -1098,6 +1098,7 @@ ProcRenderAddGlyphs (ClientPtr client)
CARD8 *bits;
int size;
int err = BadAlloc;
int i;
REQUEST_AT_LEAST_SIZE(xRenderAddGlyphsReq);
glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client,
@ -1131,7 +1132,7 @@ ProcRenderAddGlyphs (ClientPtr client)
gi = (xGlyphInfo *) (gids + nglyphs);
bits = (CARD8 *) (gi + nglyphs);
remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs;
while (remain >= 0 && nglyphs)
for (i = 0; i < nglyphs; i++)
{
glyph = AllocateGlyph (gi, glyphSet->fdepth);
if (!glyph)
@ -1155,21 +1156,19 @@ ProcRenderAddGlyphs (ClientPtr client)
gi++;
gids++;
glyphs++;
nglyphs--;
}
if (nglyphs || remain)
if (remain || i < nglyphs)
{
err = BadLength;
goto bail;
}
nglyphs = stuff->nglyphs;
if (!ResizeGlyphSet (glyphSet, nglyphs))
{
err = BadAlloc;
goto bail;
}
glyphs = glyphsBase;
while (nglyphs--) {
for (i = 0; i < nglyphs; i++) {
AddGlyph (glyphSet, glyphs->glyph, glyphs->id);
glyphs++;
}