diff options
author | Ulrich Sibiller <uli42@gmx.de> | 2016-10-26 10:39:37 +0200 |
---|---|---|
committer | Ulrich Sibiller <uli42@gmx.de> | 2016-11-08 07:33:48 +0100 |
commit | d37f9f31176ab94304fcc72b4aef507e2147005a (patch) | |
tree | 44ad72830233bfc70efe9f8a5a8d719a26f6c9df /nx-X11/programs/Xserver/hw | |
parent | e52799d5ce5189387a90b9d44f421ae90d00175c (diff) | |
download | nx-libs-d37f9f31176ab94304fcc72b4aef507e2147005a.tar.gz nx-libs-d37f9f31176ab94304fcc72b4aef507e2147005a.tar.bz2 nx-libs-d37f9f31176ab94304fcc72b4aef507e2147005a.zip |
Reconnect.c: simplify code by using strndup
Also abort reconnect on strndup failure.
Diffstat (limited to 'nx-X11/programs/Xserver/hw')
-rw-r--r-- | nx-X11/programs/Xserver/hw/nxagent/Reconnect.c | 16 |
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; } |