the va_arg call for the argv[]-terminating null pointer was missing, so this pointer was being wrongly used as the environment pointer. issue reported by Timo Teräs. proposed patch slightly modified to simplify the resulting code.
the old versions worked, but conflicted with programs which declared their own prototypes and generated warnings with some versions of gcc.