From 891f24c6521d8c84ab900810b85f41affba9a42e Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Sat, 25 Jan 2020 23:05:14 +0100 Subject: Display.c: fix common realloc mistake As reported by static analyzer: (error) Common realloc mistake: 'nxagentVisuals' nulled but not freed upon failure --- nx-X11/programs/Xserver/hw/nxagent/Display.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Display.c b/nx-X11/programs/Xserver/hw/nxagent/Display.c index c8ad891be..bc85d821d 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Display.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Display.c @@ -1494,8 +1494,13 @@ void nxagentInitVisuals(void) if (nxagentVisuals != NULL) { - nxagentVisuals = (XVisualInfo *) realloc(nxagentVisuals, - nxagentNumVisuals * sizeof(XVisualInfo)); + XVisualInfo *new = (XVisualInfo *) realloc(nxagentVisuals, + nxagentNumVisuals * sizeof(XVisualInfo)); + /* nxagentVisuals being NULL is covered below */ + if (new) + nxagentVisuals = new; + else + SAFE_free(nxagentVisuals); } SAFE_XFree(viList); -- cgit v1.2.3