[X2Go-Commits] [nx-libs] 181/429: Display.c: prevent PVS Studio realloc warning
git-admin at x2go.org
git-admin at x2go.org
Mon Oct 18 09:36:25 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 67c7513bfc18c5bcb94ea152823601970a18d7f3
Author: Ulrich Sibiller <uli42 at gmx.de>
Date: Mon Jan 4 16:28:27 2021 +0100
Display.c: prevent PVS Studio realloc warning
"V701 realloc() possible leak: when realloc() fails in allocating
memory, original pointer 'nxagentDefaultColormaps' is lost. Consider
assigning realloc() to a temporary pointer."
---
nx-X11/programs/Xserver/hw/nxagent/Display.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Display.c b/nx-X11/programs/Xserver/hw/nxagent/Display.c
index 15112312f..9931bdd77 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Display.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Display.c
@@ -2577,12 +2577,18 @@ Bool nxagentReconnectDisplay(void *p0)
nxagentNumDefaultColormaps = nxagentNumVisuals;
- nxagentDefaultColormaps = (Colormap *) realloc(nxagentDefaultColormaps,
- nxagentNumDefaultColormaps * sizeof(Colormap));
-
- if (nxagentDefaultColormaps == NULL)
{
- FatalError("Can't allocate memory for the default colormaps\n");
+ Colormap * tmp = (Colormap *) realloc(nxagentDefaultColormaps,
+ nxagentNumDefaultColormaps * sizeof(Colormap));
+ if (tmp == NULL)
+ {
+ SAFE_free(nxagentDefaultColormaps);
+ FatalError("Can't allocate memory for the default colormaps\n");
+ }
+ else
+ {
+ nxagentDefaultColormaps = tmp;
+ }
}
reconnectDisplayState = ALLOC_DEF_COLORMAP;
--
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