diff options
author | Paul Smith <psmith@gnu.org> | 2014-10-20 01:54:56 -0400 |
---|---|---|
committer | Paul Smith <psmith@gnu.org> | 2014-10-20 01:54:56 -0400 |
commit | 292da6f6867b75a5af7ddbb639a1feae022f438f (patch) | |
tree | defaed7701a30a52b7ba0c6d03f7cd895ae157b6 | |
parent | 3c487e7ed54bcfe9c83cb4cbb66549c5d42692fe (diff) | |
download | gunmake-292da6f6867b75a5af7ddbb639a1feae022f438f.tar.gz |
* main.c (main): [SV 43434] Handle NULL returns from ttyname().
-rw-r--r-- | main.c | 15 | ||||
-rw-r--r-- | makeint.h | 3 |
2 files changed, 12 insertions, 6 deletions
@@ -1429,13 +1429,18 @@ main (int argc, char **argv, char **envp) #ifdef HAVE_ISATTY if (isatty (fileno (stdout))) if (! lookup_variable (STRING_SIZE_TUPLE ("MAKE_TERMOUT"))) - define_variable_cname ("MAKE_TERMOUT", TTYNAME (fileno (stdout)), - o_default, 0)->export = v_export; - + { + const char *tty = TTYNAME (fileno (stdout)); + define_variable_cname ("MAKE_TERMOUT", tty ? tty : DEFAULT_TTYNAME, + o_default, 0)->export = v_export; + } if (isatty (fileno (stderr))) if (! lookup_variable (STRING_SIZE_TUPLE ("MAKE_TERMERR"))) - define_variable_cname ("MAKE_TERMERR", TTYNAME (fileno (stderr)), - o_default, 0)->export = v_export; + { + const char *tty = TTYNAME (fileno (stderr)); + define_variable_cname ("MAKE_TERMERR", tty ? tty : DEFAULT_TTYNAME, + o_default, 0)->export = v_export; + } #endif /* Reset in case the switches changed our minds. */ @@ -436,10 +436,11 @@ extern struct rlimit stack_limit; /* The number of bytes needed to represent the largest integer as a string. */ #define INTSTR_LENGTH CSTRLEN ("18446744073709551616") +#define DEFAULT_TTYNAME "true" #ifdef HAVE_TTYNAME # define TTYNAME(_f) ttyname (_f) #else -# define TTYNAME(_f) "true" +# define TTYNAME(_f) DEFAULT_TTYNAME #endif |