dlg_listbox_select() now scrolls the list box to ensure that the
[sgt/putty] / unix / uxpty.c
index b3bda08..c317437 100644 (file)
@@ -744,7 +744,9 @@ static const char *pty_init(void *frontend, void **backend_handle, Config *cfg,
        dup2(slavefd, 1);
        dup2(slavefd, 2);
        setsid();
+#ifdef TIOCSCTTY
        ioctl(slavefd, TIOCSCTTY, 1);
+#endif
        pgrp = getpid();
        tcsetpgrp(slavefd, pgrp);
        setpgid(pgrp, pgrp);
@@ -754,15 +756,19 @@ static const char *pty_init(void *frontend, void **backend_handle, Config *cfg,
        for (i = 3; i < 1024; i++)
            close(i);
        {
-           char term_env_var[10 + sizeof(cfg->termtype)];
-           sprintf(term_env_var, "TERM=%s", cfg->termtype);
+           char *term_env_var = dupprintf("TERM=%s", cfg->termtype);
            putenv(term_env_var);
+           /* We mustn't free term_env_var, as putenv links it into the
+            * environment in place.
+            */
        }
 #ifndef NOT_X_WINDOWS                 /* for Mac OS X native compilation */
        {
-           char windowid_env_var[40];
-           sprintf(windowid_env_var, "WINDOWID=%ld", windowid);
+           char *windowid_env_var = dupprintf("WINDOWID=%ld", windowid);
            putenv(windowid_env_var);
+           /* We mustn't free windowid_env_var, as putenv links it into the
+            * environment in place.
+            */
        }
 #endif
        {