summaryrefslogtreecommitdiff
path: root/Xi
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2015-03-21 11:07:24 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2015-04-21 16:57:07 -0700
commitf3ba909753cd216fc9eca4618a76cc283ccbf51e (patch)
tree1b48b1c08c341b26ed8d74e339308893021dccbe /Xi
parenta28202a148508837911c5932a0d14af4b145bece (diff)
Let calloc handle multiplication
It's going to multiply anyway, so if we have non-constant values, might as well let it do the multiplication instead of adding another multiply, and good versions of calloc will check for & avoid overflow in the process. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Matt Turner <mattst88@gmail.com>
Diffstat (limited to 'Xi')
-rw-r--r--Xi/xiquerypointer.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/Xi/xiquerypointer.c b/Xi/xiquerypointer.c
index 7ec0c851d..b9e295815 100644
--- a/Xi/xiquerypointer.c
+++ b/Xi/xiquerypointer.c
@@ -152,10 +152,10 @@ ProcXIQueryPointer(ClientPtr client)
rep.buttons_len =
bytes_to_int32(bits_to_bytes(pDev->button->numButtons));
rep.length += rep.buttons_len;
- buttons_size = rep.buttons_len * 4;
- buttons = calloc(1, buttons_size);
+ buttons = calloc(rep.buttons_len, 4);
if (!buttons)
return BadAlloc;
+ buttons_size = rep.buttons_len * 4;
for (i = 1; i < pDev->button->numButtons; i++)
if (BitIsOn(pDev->button->down, i))