[X2Go-Commits] [nx-libs] 175/429: Atoms.c: silence PVS Studio warning

git-admin at x2go.org git-admin at x2go.org
Mon Oct 18 09:36:24 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 36d7e152f1bb977517d0c6f764781d287cf01c26
Author: Ulrich Sibiller <uli42 at gmx.de>
Date:   Mon Aug 3 16:27:41 2020 +0200

    Atoms.c: silence PVS Studio warning
    
    "V701 realloc() possible leak: when realloc() fails in allocating
    memory, original pointer 'privAtomMap' is lost. Consider assigning
    realloc() to a temporary pointer."
---
 nx-X11/programs/Xserver/hw/nxagent/Atoms.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/nx-X11/programs/Xserver/hw/nxagent/Atoms.c b/nx-X11/programs/Xserver/hw/nxagent/Atoms.c
index 2daad061e..61953e2a6 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Atoms.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Atoms.c
@@ -385,12 +385,16 @@ static void nxagentExpandCache(void)
 {
   privAtomMapSize += NXAGENT_ATOM_MAP_SIZE_INCREMENT;
 
-  privAtomMap = realloc(privAtomMap, privAtomMapSize * sizeof(AtomMap));
+  AtomMap * newmap = realloc(privAtomMap, privAtomMapSize * sizeof(AtomMap));
 
-  if (privAtomMap == NULL)
+  if (newmap == NULL)
   {
     FatalError("nxagentExpandCache: realloc failed\n");
   }
+  else
+  {
+    privAtomMap = newmap;
+  }
 }
 
 /*

--
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