[X2Go-Commits] [nx-libs] 185/429: Reconnect.c: fix possible realloc() memory loss

git-admin at x2go.org git-admin at x2go.org
Mon Oct 18 09:36:26 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 8bb77997f8e7828846d68a02e8e1f00571f3a4f5
Author: Ulrich Sibiller <uli42 at gmx.de>
Date:   Mon Jan 4 18:04:29 2021 +0100

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

diff --git a/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c b/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c
index d0f83e7bd..e6d3ce6ec 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c
@@ -788,12 +788,16 @@ void nxagentSetReconnectError(int id, char *format, ...)
       size = (size ? size * 2 : NXAGENT_RECONNECT_DEFAULT_MESSAGE_SIZE);
     }
 
-    nxagentReconnectErrorMessage = realloc(nxagentReconnectErrorMessage, size);
+    char *tmp = realloc(nxagentReconnectErrorMessage, size);
 
-    if (nxagentReconnectErrorMessage == NULL)
+    if (tmp == NULL)
     {
       FatalError("realloc failed");
     }
+    else
+    {
+      nxagentReconnectErrorMessage = tmp;
+    }
   }
 
   return;

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