[X2Go-Commits] [nx-libs] 189/429: Screen.c: check for malloc failures
git-admin at x2go.org
git-admin at x2go.org
Mon Oct 18 09:36:26 CEST 2021
This is an automated email from the git hooks/post-receive script.
x2go pushed a commit to branch 3.6.x
in repository nx-libs.
commit 6214c71b32aa3562aeff08ffa63e67323a2cc05b
Author: Ulrich Sibiller <uli42 at gmx.de>
Date: Mon Jan 4 19:07:06 2021 +0100
Screen.c: check for malloc failures
PVS finding: "V522 There might be dereferencing of a potential null pointer"
---
nx-X11/programs/Xserver/hw/nxagent/Screen.c | 39 +++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c
index 86f88bb7b..cff0eb76a 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c
@@ -1156,6 +1156,14 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, int argc, char *argv[])
*/
DepthPtr depths = (DepthPtr) malloc(nxagentNumDepths * sizeof(DepthRec));
+ if (!depths)
+ {
+ #ifdef WARNING
+ fprintf(stderr, "WARNING: Could not allocate depths array\n");
+ #endif
+ /* FIXME: free data allocated above */
+ return False;
+ }
for (int i = 0; i < nxagentNumDepths; i++)
{
@@ -1177,6 +1185,14 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, int argc, char *argv[])
int numDepths = nxagentNumDepths;
VisualPtr visuals = (VisualPtr) malloc(nxagentNumVisuals * sizeof(VisualRec));
+ if (!visuals)
+ {
+ #ifdef WARNING
+ fprintf(stderr, "WARNING: Could not allocate visual array\n");
+ #endif
+ /* FIXME: free data allocated above */
+ return False;
+ }
int defaultVisualIndex = 0;
@@ -3058,6 +3074,14 @@ void nxagentShadowAdaptDepth(unsigned int width, unsigned int height,
unsigned char *cBuffer = malloc(length);
unsigned char *icBuffer = cBuffer;
+ if (!cBuffer)
+ {
+ #ifdef WARNING
+ fprintf(stderr, "WARNING: could not allocate cBuffer\n");
+ #endif
+ return;
+ }
+
Visual *pVisual = nxagentImageVisual((DrawablePtr) nxagentShadowPixmapPtr, nxagentShadowDepth);
if (pVisual == NULL)
@@ -4203,6 +4227,13 @@ void nxagentSaveAreas(PixmapPtr pPixmap, RegionPtr prgnSave, int xorg, int yorg,
int nRects = RegionNumRects(&cleanRegion);
int size = nRects * sizeof(XRectangle);
XRectangle *pRects = (XRectangle *) malloc(size);
+ if (!pRects)
+ {
+ #ifdef WARNING
+ fprintf(stderr, "Could not allocate pRects\n");
+ #endif
+ return;
+ }
BoxPtr pBox = RegionRects(&cleanRegion);
for (int i = nRects; i-- > 0;)
@@ -4336,6 +4367,14 @@ void nxagentRestoreAreas(PixmapPtr pPixmap, RegionPtr prgnRestore, int xorg,
int nRects = RegionNumRects(clipRegion);
int size = nRects * sizeof(XRectangle);
XRectangle *pRects = (XRectangle *) malloc(size);
+ if (!pRects)
+ {
+ #ifdef WARNING
+ fprintf(stderr, "Could not allocate pRects\n");
+ #endif
+ return;
+ }
+
BoxPtr pBox = RegionRects(clipRegion);
for (int i = nRects; i-- > 0;)
--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/nx-libs.git
More information about the x2go-commits
mailing list