diff options
author | Daniel Drake <d.drake@mmm.com> | 2007-12-28 16:04:11 +1030 |
---|---|---|
committer | Peter Hutterer <peter@cs.unisa.edu.au> | 2007-12-28 16:07:23 +1030 |
commit | e4071358e3047127fe0476cab3e9fb63e180e940 (patch) | |
tree | 3e1a20fb28b2597efc7e34e948f523b01452c8ad /src/xf86Elo.c | |
parent | 768c17328041e2f3e59d25251772cb3be164ba71 (diff) |
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>
Diffstat (limited to 'src/xf86Elo.c')
-rw-r--r-- | src/xf86Elo.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/xf86Elo.c b/src/xf86Elo.c index 7449abd..3e936af 100644 --- a/src/xf86Elo.c +++ b/src/xf86Elo.c @@ -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"); } |