Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Fix issue 11594: Check if the monitor is null in _d_monitorenter
Browse files Browse the repository at this point in the history
In case of

```
        synchronized (null)
        {
                // ...
        }
```

runtime will try to access __monitor field on a null,
without checking if it's a null and it will segfault,
leaving programmer clueless.

https://issues.dlang.org/show_bug.cgi?id=11594
  • Loading branch information
Burgos committed May 7, 2017
1 parent f4095df commit a2ead6d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/rt/monitor_.d
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ extern (C) void _d_monitordelete(Object h, bool det)
}

extern (C) void _d_monitorenter(Object h)
in
{
assert(h !is null, "Synchronized object must not be null.");
}
body
{
auto m = cast(Monitor*) ensureMonitor(h);
auto i = m.impl;
Expand Down

0 comments on commit a2ead6d

Please sign in to comment.