Skip to content

Commit

Permalink
X11 backend wont crash with 0 sized window.
Browse files Browse the repository at this point in the history
  • Loading branch information
danwalmsley committed Jan 20, 2020
1 parent fdfd5be commit d491098
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/Shared/PlatformSupport/StandardRuntimePlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@ static UnmanagedBlob()

public UnmanagedBlob(StandardRuntimePlatform plat, int size)
{
if (size <= 0)
throw new ArgumentException("Positive number required", nameof(size));
_plat = plat;
_address = plat.Alloc(size);
GC.AddMemoryPressure(size);
if (size > 0)
{
_plat = plat;
_address = plat.Alloc(size);
GC.AddMemoryPressure(size);
}

Size = size;
#if DEBUG
_backtrace = Environment.StackTrace;
Expand All @@ -75,7 +77,7 @@ void DoDispose()
lock (_btlock)
Backtraces.Remove(_backtrace);
#endif
_plat.Free(_address, Size);
_plat?.Free(_address, Size);
GC.RemoveMemoryPressure(Size);
IsDisposed = true;
_address = IntPtr.Zero;
Expand Down

0 comments on commit d491098

Please sign in to comment.