diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2021-01-16 00:24:10 +0100 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2021-01-16 00:24:10 +0100 |
commit | 8c3bb27150bf058c007af1318cb477e9763b9d9d (patch) | |
tree | 794b78e31d0ffdff0a41ecec3869afee542410ba /nx-X11/programs/Xserver/hw/nxagent/Screen.c | |
parent | b66699555d2e2503926f01a9c192481e01812399 (diff) | |
parent | 1b80750f69a848c1c00c15c537707acca4e68684 (diff) | |
download | nx-libs-8c3bb27150bf058c007af1318cb477e9763b9d9d.tar.gz nx-libs-8c3bb27150bf058c007af1318cb477e9763b9d9d.tar.bz2 nx-libs-8c3bb27150bf058c007af1318cb477e9763b9d9d.zip |
Merge branch 'uli42-pr/pvs_findings' into 3.6.x
Attributes GH PR #981: https://github.com/ArcticaProject/nx-libs/pull/981
Diffstat (limited to 'nx-X11/programs/Xserver/hw/nxagent/Screen.c')
-rw-r--r-- | nx-X11/programs/Xserver/hw/nxagent/Screen.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index d09c14692..173d2fb82 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;) |