diff options
| author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2024-08-26 14:38:01 -0700 |
|---|---|---|
| committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2024-08-26 14:38:01 -0700 |
| commit | a329f664330407480ecb4505c79dca5eab06dcff (patch) | |
| tree | c8b92ef0b9864d23543ee911fd9b2b29d473ad7d | |
| parent | 6bbbcf9218bbc686389387142978f90a3917c39a (diff) | |
XPresentWireToCookie: avoid writing to NULL pointer if malloc() fails
Fixes 3 -Wanalyzer-possible-null-dereference warnings from gcc 14.1
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libxpresent/-/merge_requests/6>
| -rw-r--r-- | src/Xpresent.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/Xpresent.c b/src/Xpresent.c index 0dad7df..e2bb47a 100644 --- a/src/Xpresent.c +++ b/src/Xpresent.c @@ -136,6 +136,8 @@ XPresentWireToCookie(Display *dpy, xPresentConfigureNotify *proto = (xPresentConfigureNotify *) ge; XPresentConfigureNotifyEvent *ce = malloc (sizeof (XPresentConfigureNotifyEvent)); cookie->data = ce; + if (ce == NULL) + break; ce->type = cookie->type; ce->serial = cookie->serial; @@ -162,6 +164,8 @@ XPresentWireToCookie(Display *dpy, xPresentCompleteNotify *proto = (xPresentCompleteNotify *) ge; XPresentCompleteNotifyEvent *ce = malloc (sizeof (XPresentCompleteNotifyEvent)); cookie->data = ce; + if (ce == NULL) + break; ce->type = cookie->type; ce->serial = cookie->serial; @@ -184,6 +188,8 @@ XPresentWireToCookie(Display *dpy, xPresentIdleNotify *proto = (xPresentIdleNotify *) ge; XPresentIdleNotifyEvent *ce = malloc (sizeof (XPresentIdleNotifyEvent)); cookie->data = ce; + if (ce == NULL) + break; ce->type = cookie->type; ce->serial = cookie->serial; @@ -209,6 +215,8 @@ XPresentWireToCookie(Display *dpy, XPresentNotify *XNotify = (XPresentNotify *) (re + 1); int i; cookie->data = re; + if (re == NULL) + break; re->type = cookie->type; re->serial = cookie->serial; |
