From 4c5b873c160b2d3ed9fbc3afa2214fca6dac4c2f Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 18 Dec 2012 09:19:04 +0000 Subject: [PATCH] Switch round a bogus if statement I've just noticed. Both the write to pty_utmp_helper_pipe _and_ the close of it if we're not going to write should be conditionalised on the pipe existing, rather than just the former! git-svn-id: svn://svn.tartarus.org/sgt/putty@9729 cda61777-01e9-0310-a592-d414129be87e --- unix/uxpty.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/unix/uxpty.c b/unix/uxpty.c index 186ff5a9..a1f96946 100644 --- a/unix/uxpty.c +++ b/unix/uxpty.c @@ -748,21 +748,23 @@ static const char *pty_init(void *frontend, void **backend_handle, Conf *conf, * Stamp utmp (that is, tell the utmp helper process to do so), * or not. */ - if (!conf_get_int(conf, CONF_stamp_utmp)) { - close(pty_utmp_helper_pipe); /* just let the child process die */ - pty_utmp_helper_pipe = -1; - } else if (pty_utmp_helper_pipe >= 0) { - char *location = get_x_display(pty->frontend); - int len = strlen(location)+1, pos = 0; /* +1 to include NUL */ - while (pos < len) { - int ret = write(pty_utmp_helper_pipe, location+pos, len - pos); - if (ret < 0) { - perror("pterm: writing to utmp helper process"); - close(pty_utmp_helper_pipe); /* arrgh, just give up */ - pty_utmp_helper_pipe = -1; - break; - } - pos += ret; + if (pty_utmp_helper_pipe >= 0) { /* if it's < 0, we can't anyway */ + if (!conf_get_int(conf, CONF_stamp_utmp)) { + close(pty_utmp_helper_pipe); /* just let the child process die */ + pty_utmp_helper_pipe = -1; + } else { + char *location = get_x_display(pty->frontend); + int len = strlen(location)+1, pos = 0; /* +1 to include NUL */ + while (pos < len) { + int ret = write(pty_utmp_helper_pipe, location+pos, len - pos); + if (ret < 0) { + perror("pterm: writing to utmp helper process"); + close(pty_utmp_helper_pipe); /* arrgh, just give up */ + pty_utmp_helper_pipe = -1; + break; + } + pos += ret; + } } } #endif -- 2.11.0