aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver/hw/nxagent/Window.c
diff options
context:
space:
mode:
authorUlrich Sibiller <uli42@gmx.de>2021-01-04 19:50:31 +0100
committerUlrich Sibiller <uli42@gmx.de>2021-01-15 19:50:37 +0100
commit4d95e29b87217ac12de97bf4031603c36055b6ac (patch)
tree13ab0fcd5c06ef6e2fe875c424b6a8d2164beba3 /nx-X11/programs/Xserver/hw/nxagent/Window.c
parent5ad0b4dde3b686d369d222976e947dcd83058757 (diff)
downloadnx-libs-4d95e29b87217ac12de97bf4031603c36055b6ac.tar.gz
nx-libs-4d95e29b87217ac12de97bf4031603c36055b6ac.tar.bz2
nx-libs-4d95e29b87217ac12de97bf4031603c36055b6ac.zip
Window.c: check for malloc failure
PVS finding: "V522 There might be dereferencing of a potential null pointer 'props'"
Diffstat (limited to 'nx-X11/programs/Xserver/hw/nxagent/Window.c')
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Window.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Window.c b/nx-X11/programs/Xserver/hw/nxagent/Window.c
index 367c15841..811b5b565 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Window.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Window.c
@@ -3090,27 +3090,36 @@ static void nxagentReconnectWindow(void * param0, XID param1, void * data_buffer
(void*)pWin, pWin -> drawable.id, nxagentWindow(pWin));
#endif
+ /* FIXME: use XAllocSizeHints() */
#ifdef _XSERVER64
data64 = (unsigned char *) malloc(sizeof(XSizeHints) + 4);
+ if (data64)
+ {
+ for (int i = 0; i < 4; i++)
+ {
+ *(data64 + i) = *(data + i);
+ }
- for (int i = 0; i < 4; i++)
- {
- *(data64 + i) = *(data + i);
- }
-
- *(((int *) data64) + 1) = 0;
+ *(((int *) data64) + 1) = 0;
- for (int i = 8; i < sizeof(XSizeHints) + 4; i++)
- {
- *(data64 + i) = *(data + i - 4);
- }
+ for (int i = 8; i < sizeof(XSizeHints) + 4; i++)
+ {
+ *(data64 + i) = *(data + i - 4);
+ }
- XSizeHints *props = (XSizeHints *) data64;
+ XSizeHints *props = (XSizeHints *) data64;
#else
- XSizeHints *props = (XSizeHints *) data;
+ XSizeHints *props = (XSizeHints *) data;
#endif /* _XSERVER64 */
- hints = *props;
+ hints = *props;
+ }
+ else
+ {
+ #ifdef WARNING
+ fprintf(stderr, "%s: Failed to alloc memory for XSizeHints\n", __func__);
+ #endif
+ }
}
else
{