aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Reconnect.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c b/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c
index c20386ea1..65e2ae795 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c
@@ -438,22 +438,14 @@ Bool nxagentReconnectSession(void)
if (nxagentKeyboard != NULL)
{
- int size;
-
- size = strlen(nxagentKeyboard);
-
- if ((nxagentOldKeyboard = malloc(size + 1)) != NULL)
+ nxagentOldKeyboard = strndup(nxagentKeyboard, strlen(nxagentKeyboard));
+ if (nxagentOldKeyboard == NULL)
{
- strncpy(nxagentOldKeyboard, nxagentKeyboard, size);
-
- nxagentOldKeyboard[size] = '\0';
+ /* 0 means reconnection failed */
+ return 0;
}
- }
- if (nxagentKeyboard)
- {
free(nxagentKeyboard);
-
nxagentKeyboard = NULL;
}