aboutsummaryrefslogtreecommitdiff
path: root/nx-X11
diff options
context:
space:
mode:
authorUlrich Sibiller <uli42@gmx.de>2021-01-04 16:28:27 +0100
committerUlrich Sibiller <uli42@gmx.de>2021-01-15 19:50:35 +0100
commit67c7513bfc18c5bcb94ea152823601970a18d7f3 (patch)
treece773cd9b823daba93db149fafc592bd57b499cc /nx-X11
parentdb134de3b9cefa6e0d76fe57f2feabe79ba9216c (diff)
downloadnx-libs-67c7513bfc18c5bcb94ea152823601970a18d7f3.tar.gz
nx-libs-67c7513bfc18c5bcb94ea152823601970a18d7f3.tar.bz2
nx-libs-67c7513bfc18c5bcb94ea152823601970a18d7f3.zip
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."
Diffstat (limited to 'nx-X11')
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Display.c16
1 files 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;