Browse Source

Supporess finalization when UnmanagedBlob allocation failed

pull/5324/head
Nikita Tsukanov 5 years ago
committed by GitHub
parent
commit
4a160e3109
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      src/Shared/PlatformSupport/StandardRuntimePlatform.cs

20
src/Shared/PlatformSupport/StandardRuntimePlatform.cs

@ -49,12 +49,20 @@ 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);
Size = size;
try
{
if (size <= 0)
throw new ArgumentException("Positive number required", nameof(size));
_plat = plat;
_address = plat.Alloc(size);
GC.AddMemoryPressure(size);
Size = size;
}
catch
{
GC.SuppressFinalize();
throw;
}
#if DEBUG
_backtrace = Environment.StackTrace;
lock (_btlock)

Loading…
Cancel
Save