From 8bb77997f8e7828846d68a02e8e1f00571f3a4f5 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 4 Jan 2021 18:04:29 +0100 Subject: 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(-) (limited to 'nx-X11/programs') 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; -- cgit v1.2.3