From ca35f249f7cd7b1cd96428d8e631afd8157f9a33 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Thu, 12 Jan 2023 21:15:51 +0100 Subject: [PATCH] Set parameters to null in public COM APIs --- .../PixelShaderEffect{T}.ICanvasImageInterop.cs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/ComputeSharp.D2D1.Uwp/PixelShaderEffect{T}.ICanvasImageInterop.cs b/src/ComputeSharp.D2D1.Uwp/PixelShaderEffect{T}.ICanvasImageInterop.cs index 94924f72..a482d837 100644 --- a/src/ComputeSharp.D2D1.Uwp/PixelShaderEffect{T}.ICanvasImageInterop.cs +++ b/src/ComputeSharp.D2D1.Uwp/PixelShaderEffect{T}.ICanvasImageInterop.cs @@ -29,6 +29,10 @@ unsafe partial class PixelShaderEffect return E.E_POINTER; } + // Set parameters to default values + *device = null; + *type = WIN2D_GET_DEVICE_ASSOCIATION_TYPE_UNSPECIFIED; + using ReferenceTracker.Lease _0 = GetReferenceTracker().TryGetLease(out bool leaseTaken); // Check for disposal @@ -78,12 +82,15 @@ unsafe partial class PixelShaderEffect float* realizeDpi, ID2D1Image** ppImage) { - // No input pointer can be null + // The device and resulting image pointers cannot be null if (device is null || ppImage is null) { return E.E_POINTER; } + // Set the resulting image to null + *ppImage = null; + using ReferenceTracker.Lease _0 = GetReferenceTracker().TryGetLease(out bool leaseTaken); // Check for disposal @@ -148,8 +155,6 @@ unsafe partial class PixelShaderEffect { if (!Realize(flags, targetDpi, deviceContext)) { - *ppImage = null; - return E.E_FAIL; } } @@ -170,12 +175,6 @@ unsafe partial class PixelShaderEffect return S.S_OK; } } - catch (Exception e) - { - *ppImage = null; - - return e.HResult; - } finally { // Ensure that reset this flag so that this method can be called again