diff options
author | Yaakov Selkowitz <yselkowitz@users.sourceforge.net> | 2013-05-04 15:18:29 +0100 |
---|---|---|
committer | Jon TURNEY <jon.turney@dronecode.org.uk> | 2013-05-04 15:18:29 +0100 |
commit | 0b1e8c1f41fdd9dd0ad9e620e8ad2e10da3cdc13 (patch) | |
tree | b4cf08bae6cc266ea3cb2ced9494e319ee889658 | |
parent | 1979e6f1d2aa5f69e401a5437f487910e3464e52 (diff) |
Fix a potential crash on startup
Change btn_labels in winMouseProc() from a dynamic allocation of potentially the
wrong size (if GetSystemMetrics(SM_CMOUSEBUTTONS) is less than 5) to a fixed one
on stack, of the required size for all the labels we create.
-rw-r--r-- | hw/xwin/winmouse.c | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/hw/xwin/winmouse.c b/hw/xwin/winmouse.c index c5de57788..59705e655 100644 --- a/hw/xwin/winmouse.c +++ b/hw/xwin/winmouse.c @@ -70,7 +70,7 @@ winMouseProc(DeviceIntPtr pDeviceInt, int iState) int lngWheelEvents = 4; CARD8 *map; DevicePtr pDevice = (DevicePtr) pDeviceInt; - Atom *btn_labels; + Atom btn_labels[9]; Atom axes_labels[2]; switch (iState) { @@ -107,8 +107,6 @@ winMouseProc(DeviceIntPtr pDeviceInt, int iState) for (i = 1; i <= lngMouseButtons + lngWheelEvents; i++) map[i] = i; - btn_labels = calloc((lngMouseButtons + lngWheelEvents), sizeof(Atom)); - btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT); btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE); btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT); @@ -129,7 +127,6 @@ winMouseProc(DeviceIntPtr pDeviceInt, int iState) winMouseCtrl, GetMotionHistorySize(), 2, axes_labels); free(map); - free(btn_labels); g_winMouseButtonMap = pDeviceInt->button->map; break; |