https://bugs.winehq.org/show_bug.cgi?id=45320
--- Comment #12 from Dima Ryazanov dima@gmail.com --- Awesome, thanks, I'll test it now.
I've looked at the code - and I think you need to do the check when calculating "count" and "len", too:
for (ptr = environ_strings; *ptr; ptr += strlen(ptr) + 1) { count++; len += strlen(ptr) + 1; }
Wasting a few bytes is probably not a big deal - but the doc string is pretty explicit about the layout of the result:
* blk is an array of pointers to environment strings, ending with a NULL * and after that the actual copy of the environment strings, ending in a \0