diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.cs index f9edc7af..6524b34e 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.cs @@ -240,7 +240,18 @@ internal unsafe partial struct PixelShaderEffect D2D1TransformMapper? d2D1TransformMapper, IUnknown** effectImpl) { - PixelShaderEffect* @this = (PixelShaderEffect*)NativeMemory.Alloc((nuint)sizeof(PixelShaderEffect)); + PixelShaderEffect* @this; + + try + { + @this = (PixelShaderEffect*)NativeMemory.Alloc((nuint)sizeof(PixelShaderEffect)); + } + catch (OutOfMemoryException) + { + *effectImpl = null; + + return E.E_OUTOFMEMORY; + } *@this = default; diff --git a/src/TerraFX.Interop.Windows.D2D1/Windows/shared/winerror/E.cs b/src/TerraFX.Interop.Windows.D2D1/Windows/shared/winerror/E.cs index e22e6bc8..a8da79de 100644 --- a/src/TerraFX.Interop.Windows.D2D1/Windows/shared/winerror/E.cs +++ b/src/TerraFX.Interop.Windows.D2D1/Windows/shared/winerror/E.cs @@ -10,6 +10,9 @@ namespace TerraFX.Interop.Windows [NativeTypeName("#define E_NOTIMPL _HRESULT_TYPEDEF_(0x80004001L)")] public const int E_NOTIMPL = unchecked((int)(0x80004001)); + [NativeTypeName("#define E_OUTOFMEMORY _HRESULT_TYPEDEF_(0x8007000EL)")] + public const int E_OUTOFMEMORY = unchecked((int)(0x8007000E)); + [NativeTypeName("#define E_INVALIDARG _HRESULT_TYPEDEF_(0x80070057L)")] public const int E_INVALIDARG = unchecked((int)(0x80070057));