From 5ad0b4dde3b686d369d222976e947dcd83058757 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 4 Jan 2021 19:44:37 +0100 Subject: Window.c: check for malloc failure PVS finding: "V522 There might be dereferencing of a potential null pointer 'nxagentConfiguredWindowList'." --- nx-X11/programs/Xserver/hw/nxagent/Window.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'nx-X11/programs/Xserver/hw/nxagent/Window.c') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Window.c b/nx-X11/programs/Xserver/hw/nxagent/Window.c index a30eac589..367c15841 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Window.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Window.c @@ -3659,6 +3659,14 @@ void nxagentAddStaticResizedWindow(WindowPtr pWin, unsigned long sequence, int o StaticResizedWindowStruct *tmp = nxagentStaticResizedWindowList; nxagentStaticResizedWindowList = malloc(sizeof(StaticResizedWindowStruct)); + if (!nxagentStaticResizedWindowList) + { + #ifdef WARNING + fprintf(stderr, "WARNING: could not allocate memory for nxagentStaticResizedWindowList\n"); + #endif + nxagentStaticResizedWindowList = tmp; + return; + } nxagentStaticResizedWindowList -> next = tmp; nxagentStaticResizedWindowList -> prev = NULL; -- cgit v1.2.3 From 4d95e29b87217ac12de97bf4031603c36055b6ac Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 4 Jan 2021 19:50:31 +0100 Subject: Window.c: check for malloc failure PVS finding: "V522 There might be dereferencing of a potential null pointer 'props'" --- nx-X11/programs/Xserver/hw/nxagent/Window.c | 35 ++++++++++++++++++----------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'nx-X11/programs/Xserver/hw/nxagent/Window.c') 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 { -- cgit v1.2.3 From 0a06ee77a2ffd2b1dc5f1d6ebe93789be12f259f Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 4 Jan 2021 14:11:31 +0100 Subject: nxagent: Drop unused nxagentRootTileWindow --- nx-X11/programs/Xserver/hw/nxagent/Window.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'nx-X11/programs/Xserver/hw/nxagent/Window.c') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Window.c b/nx-X11/programs/Xserver/hw/nxagent/Window.c index 811b5b565..d5b0c1b6a 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Window.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Window.c @@ -110,8 +110,6 @@ extern WindowPtr nxagentViewportFrameRight; extern WindowPtr nxagentViewportFrameAbove; extern WindowPtr nxagentViewportFrameBelow; -extern WindowPtr nxagentRootTileWindow; - extern Bool nxagentReportPrivateWindowIds; #define RECTLIMIT 25 -- cgit v1.2.3 From 12b96fd9abb9289039cb71a03703dcfc503f61e1 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 4 Jan 2021 14:12:05 +0100 Subject: fix formatting and spelling in various files --- nx-X11/programs/Xserver/hw/nxagent/Window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nx-X11/programs/Xserver/hw/nxagent/Window.c') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Window.c b/nx-X11/programs/Xserver/hw/nxagent/Window.c index d5b0c1b6a..841ee3888 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Window.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Window.c @@ -1530,7 +1530,7 @@ void nxagentConfigureWindow(WindowPtr pWin, unsigned int mask) * position in the window tree, and pPriorParent is its previous * parent. This function can be NULL. * - * We simply pass this pver to the real X server. + * We simply pass this over to the real X server. */ void nxagentReparentWindow(WindowPtr pWin, WindowPtr pOldParent) { -- cgit v1.2.3 From 669299de3594e46fd67a84066be4b78f83cb6f00 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 4 Jan 2021 14:57:32 +0100 Subject: Window.c: suppress warning This used to be printed only in TEST mode. Some while ago I had changed that to WARNING (because it is a warning...). However, this happens e.g. when running the xscreensaver vfeedback module and it does not look like it is a problem at all. So let's suppress this warning again and leave it to the TEST mode as it used to be. --- nx-X11/programs/Xserver/hw/nxagent/Window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nx-X11/programs/Xserver/hw/nxagent/Window.c') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Window.c b/nx-X11/programs/Xserver/hw/nxagent/Window.c index 841ee3888..d95f8f3ed 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Window.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Window.c @@ -3922,7 +3922,7 @@ StoringPixmapPtr nxagentFindItemBSPixmapList(unsigned long pixmapId) } } - #ifdef WARNING + #ifdef TEST fprintf(stderr, "%s: WARNING! Item not found.\n", __func__); #endif -- cgit v1.2.3