File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -343,6 +343,8 @@ static:
343
343
*/
344
344
bool opBinaryRight (string op : " in" )(scope const (char )[] name) @trusted
345
345
{
346
+ if (name is null )
347
+ return false ;
346
348
version (Posix )
347
349
return core.sys.posix.stdlib.getenv (name.tempCString()) ! is null ;
348
350
else version (Windows )
@@ -444,6 +446,10 @@ private:
444
446
// doesn't exist.
445
447
void getImpl (scope const (char )[] name, scope void delegate (const (OSChar)[]) @safe sink) @trusted
446
448
{
449
+ // fix issue https://issues.dlang.org/show_bug.cgi?id=24549
450
+ if (name is null )
451
+ return sink (null );
452
+
447
453
version (Windows )
448
454
{
449
455
// first we ask windows how long the environment variable is,
@@ -593,6 +599,15 @@ private:
593
599
assert (" std_process" ! in environment);
594
600
}
595
601
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
+
596
611
// =============================================================================
597
612
// Functions and classes for process management.
598
613
// =============================================================================
You can’t perform that action at this time.
0 commit comments