summaryrefslogtreecommitdiff
path: root/os
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2016-01-01 17:34:41 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2016-01-05 12:09:18 -0800
commitba71b69f94f00a6f6910597185610668e79c10be (patch)
treeeb3874b7bd5b79cacf6013d5e82e9ee901bc4560 /os
parentedcb6426f20c3be5dd5f50b76a686754aef2f64e (diff)
Avoid segfault in CloseWellKnownConnections when using -displayfd
When -displayfd is looping through the possible display ids to use, if it can't open all the listening sockets for one (say when :0 is already in use), it calls CloseWellKnownConnections to close all the ListenTransConns entries before the point that ListenTransFds was allocated & initialized, so CloseWellKnownConnections would segfault trying to read entries from a NULL ListenTransFds pointer. Introduced by commit 7b02f0b8 Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'os')
-rw-r--r--os/connection.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/os/connection.c b/os/connection.c
index 8e7513902..2a4fc8db8 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -523,7 +523,8 @@ CloseWellKnownConnections(void)
if (ListenTransConns[i] != NULL) {
_XSERVTransClose(ListenTransConns[i]);
ListenTransConns[i] = NULL;
- RemoveNotifyFd(ListenTransFds[i]);
+ if (ListenTransFds != NULL)
+ RemoveNotifyFd(ListenTransFds[i]);
}
}
ListenTransCount = 0;