Browse Source

Supporess finalization when UnmanagedBlob allocation failed

pull/5324/head
Nikita Tsukanov 6 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) public UnmanagedBlob(StandardRuntimePlatform plat, int size)
{ {
if (size <= 0) try
throw new ArgumentException("Positive number required", nameof(size)); {
_plat = plat; if (size <= 0)
_address = plat.Alloc(size); throw new ArgumentException("Positive number required", nameof(size));
GC.AddMemoryPressure(size); _plat = plat;
Size = size; _address = plat.Alloc(size);
GC.AddMemoryPressure(size);
Size = size;
}
catch
{
GC.SuppressFinalize();
throw;
}
#if DEBUG #if DEBUG
_backtrace = Environment.StackTrace; _backtrace = Environment.StackTrace;
lock (_btlock) lock (_btlock)

Loading…
Cancel
Save