[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
NULL environ?
From: |
Simon Josefsson |
Subject: |
NULL environ? |
Date: |
Mon, 27 Sep 2010 10:35:42 +0200 |
User-agent: |
Gnus/5.110011 (No Gnus v0.11) Emacs/23.2 (gnu/linux) |
Does POSIX permit a NULL 'environ' variable? I'd say no given what
http://www.opengroup.org/onlinepubs/9699919799/functions/environ.html
has to say:
In addition, the following variable:
extern char **environ;
is initialized as a pointer to an array of character pointers to the
environment strings. The argv and environ arrays are each terminated
by a null pointer.
Strictly speaking, I don't think NULL is a valid array of character
pointers terminated with a null pointer.
I've noticed that Wine uses one:
address@hidden:~$ cat environ-wine.c
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
int main (void)
{
if (environ == NULL)
puts("NULL");
else
puts("non-NULL");
return 0;
}
address@hidden:~$ i686-w64-mingw32-gcc -o environ-wine.exe environ-wine.c
address@hidden:~$ ./environ-wine.exe
NULL
address@hidden:~$
The same EXE file prints non-NULL on real Windows.
This crashes the test-environ.c and test-unsetenv.c self tests.
/Simon
- NULL environ?,
Simon Josefsson <=