diff --git a/xkb/xkb.c b/xkb/xkb.c index 15ee8ba04..1ab8dd732 100644 --- a/xkb/xkb.c +++ b/xkb/xkb.c @@ -5563,10 +5563,22 @@ _CheckSetShapes(XkbGeometryPtr geom, ol->num_points = olWire->nPoints; olWire = (xkbOutlineWireDesc *)ptWire; } - if (shapeWire->primaryNdx != XkbNoShape) + if (shapeWire->primaryNdx != XkbNoShape) { + if (shapeWire->primaryNdx >= shapeWire->nOutlines) { + client->errorValue = _XkbErrCode3(0x08, shapeWire->primaryNdx, + shapeWire->nOutlines); + return BadValue; + } shape->primary = &shape->outlines[shapeWire->primaryNdx]; - if (shapeWire->approxNdx != XkbNoShape) + } + if (shapeWire->approxNdx != XkbNoShape) { + if (shapeWire->approxNdx >= shapeWire->nOutlines) { + client->errorValue = _XkbErrCode3(0x08, shapeWire->approxNdx, + shapeWire->nOutlines); + return BadValue; + } shape->approx = &shape->outlines[shapeWire->approxNdx]; + } shapeWire = (xkbShapeWireDesc *) olWire; } wire = (char *) shapeWire;