Commit 4c5c8d62 authored by Emilio Pozuelo Monfort's avatar Emilio Pozuelo Monfort Committed by Peter Hutterer

Check that allocating a buffer succeeded

Since we are going to write into the buffer, we should make sure the
allocation didn't fail.
Reported-by: Julien Cristau's avatarJulien Cristau <jcristau@debian.org>
Signed-off-by: default avatarEmilio Pozuelo Monfort <pochu@debian.org>
Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
parent 7ac03c6c
......@@ -66,17 +66,18 @@ XIQueryDevice(Display *dpy, int deviceid, int *ndevices_return)
{
*ndevices_return = reply.num_devices;
info = Xmalloc((reply.num_devices + 1) * sizeof(XIDeviceInfo));
buf = Xmalloc(reply.length * 4);
}
else
{
*ndevices_return = 0;
info = NULL;
buf = NULL;
}
if (!info)
if (!info || !buf)
goto error;
buf = Xmalloc(reply.length * 4);
_XRead(dpy, buf, reply.length * 4);
ptr = buf;
end = buf + reply.length * 4;
......@@ -135,9 +136,9 @@ error_loop:
Xfree(info[i].name);
Xfree(info[i].classes);
}
error:
Xfree(info);
Xfree(buf);
error:
UnlockDisplay(dpy);
error_unlocked:
SyncHandle();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment