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 <igor.v.kovalenko@gmail.com>
This commit is contained in:
Igor V. Kovalenko 2021-09-05 10:25:38 +03:00
parent e92efc63ac
commit 2356e59ff2

View file

@ -559,7 +559,7 @@ extern void *_XGetRequest(Display *dpy, CARD8 type, size_t len);
#define GetResReq(name, rid, req) \
req = (xResourceReq *) _XGetRequest(dpy, X_##name, SIZEOF(xResourceReq)); \
req->id = (rid)
if (req) req->id = (rid)
/*
* GetEmptyReq is for those requests that have no arguments