From f71d916b60079f2009a714e49cb3e83efedbfb77 Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Thu, 3 May 2007 22:57:56 +0000 Subject: [PATCH] awk: guard against empty environment --- editors/awk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/editors/awk.c b/editors/awk.c index 5a504d034..bc9e99a6f 100644 --- a/editors/awk.c +++ b/editors/awk.c @@ -2696,7 +2696,8 @@ int awk_main(int argc, char **argv) newfile("/dev/stdout")->F = stdout; newfile("/dev/stderr")->F = stderr; - for (envp = environ; *envp; envp++) { + /* Huh, people report that sometimes environ is NULL. Oh well. */ + if (environ) for (envp = environ; *envp; envp++) { char *s = xstrdup(*envp); char *s1 = strchr(s, '='); if (s1) { -- 2.25.1