3eec5b9b3b8bf2f66072143c14eed7134b5261a2 — Chris Vittal 21 days ago 599fbbb
env: fix potential NULL pointer dereference

The two points where the elements of environ are accessed need to be
guarded with a NULL check. env can segfault otherwise.
1 files changed, 1 insertions(+), 1 deletions(-)

M src/env.c
M src/env.c => src/env.c +1 -1
@@ 57,7 57,7 @@
 
 	/* No command, print the env */
 	if (cmd_idx == argc) {
-		for (int i = 0; environ[i]; i++) {
+		for (int i = 0; environ && environ[i]; i++) {
 			puts(environ[i]);
 		}
 		return 0;