From d49109877c887416f146a09d9c83d0bbae3e4abe Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Mon, 20 Jan 2020 11:47:04 -0300 Subject: [PATCH] X11 backend wont crash with 0 sized window. --- .../PlatformSupport/StandardRuntimePlatform.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Shared/PlatformSupport/StandardRuntimePlatform.cs b/src/Shared/PlatformSupport/StandardRuntimePlatform.cs index 8a5a725594..499f263a9a 100644 --- a/src/Shared/PlatformSupport/StandardRuntimePlatform.cs +++ b/src/Shared/PlatformSupport/StandardRuntimePlatform.cs @@ -52,11 +52,13 @@ namespace Avalonia.Shared.PlatformSupport 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; @@ -75,7 +77,7 @@ namespace Avalonia.Shared.PlatformSupport lock (_btlock) Backtraces.Remove(_backtrace); #endif - _plat.Free(_address, Size); + _plat?.Free(_address, Size); GC.RemoveMemoryPressure(Size); IsDisposed = true; _address = IntPtr.Zero;