Read each pointer in the argv and envp arrays before dereferencing it;
this correctly marks an error when these pointers point into memory that
has been freed.
Also accept nullptr argv and envp on Linux. Per the posix_spawn manual:
The argv and envp arguments specify the argument list and environment
for the program that is executed in the child process, as for execve(2).
and then the execve manual:
On Linux, argv and envp can be specified as NULL. In both cases, this
has the same effect as specifying the argument as a pointer to a list
containing a single null pointer.
Hm, somehow I missed it, however I don't see envp == null in man page.
Lets keep them both.
And can you please remove #if, and do that for all platforms.