Skip to content

Commit 4040472

Browse files
authored
Merge pull request dlang#9006 from ibuclaw/merge_stable
merge stable
2 parents acd2013 + 3a59a5a commit 4040472

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

std/process.d

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,8 @@ static:
343343
*/
344344
bool opBinaryRight(string op : "in")(scope const(char)[] name) @trusted
345345
{
346+
if (name is null)
347+
return false;
346348
version (Posix)
347349
return core.sys.posix.stdlib.getenv(name.tempCString()) !is null;
348350
else version (Windows)
@@ -444,6 +446,10 @@ private:
444446
// doesn't exist.
445447
void getImpl(scope const(char)[] name, scope void delegate(const(OSChar)[]) @safe sink) @trusted
446448
{
449+
// fix issue https://issues.dlang.org/show_bug.cgi?id=24549
450+
if (name is null)
451+
return sink(null);
452+
447453
version (Windows)
448454
{
449455
// first we ask windows how long the environment variable is,
@@ -593,6 +599,15 @@ private:
593599
assert("std_process" !in environment);
594600
}
595601

602+
// https://issues.dlang.org/show_bug.cgi?id=24549
603+
@safe unittest
604+
{
605+
import std.exception : assertThrown;
606+
assert(environment.get(null) is null);
607+
assertThrown(environment[null]);
608+
assert(!(null in environment));
609+
}
610+
596611
// =============================================================================
597612
// Functions and classes for process management.
598613
// =============================================================================

0 commit comments

Comments
 (0)