libX11: do not crash in GetResReq() macro

When _XGetRequest() detects that requested length exceeds remaining display
output buffer capacity it would return NULL. GetResReq() macro obtains "req"
pointer from a call to _XGetRequest() and then proceeds to assign request id
through "req" pointer which leads to NULL pointer dereference in this case.

Fix this by checking if "req" is valid before assigning request id.

Signed-off-by: Igor V. Kovalenko <>
4 jobs for pr/safe-GetResReq in 10 minutes and 32 seconds (queued for 15 seconds)