Bug #9803: Don't allow zero-sized width/height.

A bad configuration can result in height or width being zero. This potentially
causes a divide-by-zero error in xf86EloConvert().
Detect the bad configuration early on and produce a meaningful error message.

X.Org Bugzilla #9803 <https://bugs.freedesktop.org/show_bug.cgi?id=9803>
This commit is contained in:
Daniel Drake
2007-12-28 16:04:11 +10:30
committed by Peter Hutterer
parent 768c173280
commit e4071358e3

View File

@@ -1691,6 +1691,7 @@ xf86EloInit(InputDriverPtr drv,
EloPrivatePtr priv=NULL;
char *str;
int portrait = 0;
int height, width;
local = xf86EloAllocate(drv);
if (!local) {
@@ -1757,11 +1758,21 @@ xf86EloInit(InputDriverPtr drv,
str = "Landscape";
}
xf86Msg(X_CONFIG, "Elographics device will work in %s mode\n", str);
if (priv->max_x - priv->min_x <= 0) {
width = priv->max_x - priv->min_x;
height = priv->max_y - priv->min_y;
if (width == 0) {
xf86Msg(X_ERROR, "Elographics: Cannot configure touchscreen with width 0\n");
return local;
}
else if (width < 0) {
xf86Msg(X_INFO, "Elographics: reverse x mode (minimum x position >= maximum x position)\n");
}
if (priv->max_y - priv->min_y <= 0) {
}
if (height == 0) {
xf86Msg(X_ERROR, "Elographics: Cannot configure touchscreen with height 0\n");
return local;
}
else if (height < 0) {
xf86Msg(X_INFO, "Elographics: reverse y mode (minimum y position >= maximum y position)\n");
}