[Issue 15783] Junk is written into environment variable after assigning null to it

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Mar 18 08:04:06 PDT 2016


https://issues.dlang.org/show_bug.cgi?id=15783

e10s <electrolysis.jp+d at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |electrolysis.jp+d at gmail.com

--- Comment #1 from e10s <electrolysis.jp+d at gmail.com> ---
Test case:

import std.conv;
import std.stdio;
import std.string;
import core.sys.posix.stdlib;

void main()
{
    immutable key = "AAAAAAAA".toStringz;
    foreach (i; 0 .. 100)
    {
        setenv(key, null, 1);
        const r = getenv(key);
        if (r && *r)
        {
            writefln("%s %s %s", i, r, r.to!string);
        }
    }
}

Result:
http://melpon.org/wandbox/permlink/cqfITPRJMSKOD60q

It's terrible. What does getenv return?

--


More information about the Digitalmars-d-bugs mailing list