diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2024-08-26 11:49:49 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2024-08-26 11:52:00 -0700 |
commit | dabce4dbe5eab35076e31fd0a628cbe11b858fa1 (patch) | |
tree | 48bf7165a5e972b3f016e5dc8dddab778d75876c | |
parent | 56b11459f833df8f324587847534a548b070da94 (diff) |
wireTo*Event: check for malloc() failure
Fixes 6 -Wanalyzer-possible-null-dereference and
1 -Wanalyzer-null-dereference and warnings from gcc 14.1
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libxi/-/merge_requests/17>
-rw-r--r-- | src/XExtInt.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/XExtInt.c b/src/XExtInt.c index a6a5f80..37473ef 100644 --- a/src/XExtInt.c +++ b/src/XExtInt.c @@ -1597,6 +1597,8 @@ wireToDeviceEvent(xXIDeviceEvent *in, XGenericEventCookie* cookie) len = sizeDeviceEvent(in->buttons_len * 4, in->valuators_len * 4, ptr); cookie->data = ptr_lib = malloc(len); + if (!ptr_lib) + return 0; out = next_block(&ptr_lib, sizeof(XIDeviceEvent)); out->display = cookie->display; @@ -1890,6 +1892,8 @@ wireToDeviceChangedEvent(xXIDeviceChangedEvent *in, XGenericEventCookie *cookie) len = size_classes((xXIAnyInfo*)&in[1], in->num_classes); cookie->data = out = malloc(sizeof(XIDeviceChangedEvent) + len); + if (!out) + return 0; out->type = in->type; out->serial = cookie->serial; @@ -1920,7 +1924,9 @@ wireToHierarchyChangedEvent(xXIHierarchyEvent *in, XGenericEventCookie *cookie) xXIHierarchyInfo *info_in; XIHierarchyEvent *out; - cookie->data = out = malloc(sizeof(XIHierarchyEvent) + in->num_info * sizeof(XIHierarchyInfo));; + cookie->data = out = malloc(sizeof(XIHierarchyEvent) + in->num_info * sizeof(XIHierarchyInfo)); + if (!out) + return 0; out->info = (XIHierarchyInfo*)&out[1]; out->display = cookie->display; @@ -2016,6 +2022,9 @@ wireToEnterLeave(xXIEnterEvent *in, XGenericEventCookie *cookie) len = sizeof(XIEnterEvent) + in->buttons_len * 4; cookie->data = out = malloc(len); + if (!out) + return 0; + out->buttons.mask = (unsigned char*)&out[1]; out->type = in->type; @@ -2060,6 +2069,8 @@ wireToPropertyEvent(xXIPropertyEvent *in, XGenericEventCookie *cookie) XIPropertyEvent *out = malloc(sizeof(XIPropertyEvent)); cookie->data = out; + if (!out) + return 0; out->type = in->type; out->serial = cookie->serial; @@ -2081,6 +2092,8 @@ wireToTouchOwnershipEvent(xXITouchOwnershipEvent *in, XITouchOwnershipEvent *out = malloc(sizeof(XITouchOwnershipEvent)); cookie->data = out; + if (!out) + return 0; out->type = in->type; out->serial = cookie->serial; @@ -2106,6 +2119,8 @@ wireToBarrierEvent(xXIBarrierEvent *in, XGenericEventCookie *cookie) XIBarrierEvent *out = malloc(sizeof(XIBarrierEvent)); cookie->data = out; + if (!out) + return 0; out->display = cookie->display; out->type = in->type; @@ -2137,6 +2152,8 @@ wireToPinchEvent(xXIGesturePinchEvent *in, XIGesturePinchEvent *out; cookie->data = out = malloc(sizeof(XIGesturePinchEvent)); + if (!out) + return 0; out->display = cookie->display; out->type = in->type; @@ -2182,6 +2199,8 @@ wireToSwipeEvent(xXIGestureSwipeEvent *in, XIGestureSwipeEvent *out; cookie->data = out = malloc(sizeof(XIGestureSwipeEvent)); + if (!out) + return 0; out->display = cookie->display; out->type = in->type; |