Skip to content
This repository was archived by the owner on Dec 12, 2024. It is now read-only.

Commit 753222d

Browse files
author
Stephen Hawley
committed
Check before allocate
1 parent b45891e commit 753222d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

SwiftRuntimeLibrary/SwiftMarshal/StructMarshal.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ public static unsafe IntPtr RetainSwiftObject (ISwiftObject obj)
2525
{
2626
if (obj == null)
2727
return IntPtr.Zero;
28-
byte* valueBuffer = stackalloc byte [3 * IntPtr.Size];
2928
if (obj.SwiftObject == IntPtr.Zero)
3029
throw new SwiftRuntimeException ("SwiftObject handle is IntPtr.Zero, likely because it was disposed.");
30+
byte* valueBuffer = stackalloc byte [3 * IntPtr.Size];
3131
SwiftCore.swift_beginAccess (obj.SwiftObject, valueBuffer, (uint)SwiftExclusivityFlags.Track, IntPtr.Zero);
3232
var result = SwiftCore.Retain (obj.SwiftObject);
3333
SwiftCore.swift_endAccess (valueBuffer);

0 commit comments

Comments
 (0)