diff options
Diffstat (limited to 'Xi')
-rw-r--r-- | Xi/exevents.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Xi/exevents.c b/Xi/exevents.c index dcd4efb3b..54ea11a93 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -611,13 +611,13 @@ DeepCopyPointerClasses(DeviceIntPtr from, DeviceIntPtr to) } if (from->button->xkb_acts) { - if (!to->button->xkb_acts) { - to->button->xkb_acts = calloc(1, sizeof(XkbAction)); - if (!to->button->xkb_acts) - FatalError("[Xi] not enough memory for xkb_acts.\n"); - } + size_t maxbuttons = max(to->button->numButtons, from->button->numButtons); + to->button->xkb_acts = xnfreallocarray(to->button->xkb_acts, + maxbuttons, + sizeof(XkbAction)); + memset(to->button->xkb_acts, 0, maxbuttons * sizeof(XkbAction)); memcpy(to->button->xkb_acts, from->button->xkb_acts, - sizeof(XkbAction)); + from->button->numButtons * sizeof(XkbAction)); } else { free(to->button->xkb_acts); |