Commit d37f9f31 authored by Ulrich Sibiller's avatar Ulrich Sibiller

Reconnect.c: simplify code by using strndup

Also abort reconnect on strndup failure.
parent e52799d5
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment