Skip to content

Commit 3c92b07

Browse files
committed
Resolve comment: SciSharp#1261 (comment)
1 parent c307006 commit 3c92b07

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

LLama/Native/MtmdContextParams.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,16 @@ private PinnedUtf8String(string value)
138138

139139
public static PinnedUtf8String? Create(string? value) => value is null ? null : new PinnedUtf8String(value);
140140

141-
public IntPtr Pointer => _buffer is null ? IntPtr.Zero : _handle.AddrOfPinnedObject();
141+
public IntPtr Pointer
142+
{
143+
get
144+
{
145+
if (_buffer is null || !_handle.IsAllocated)
146+
return IntPtr.Zero;
147+
148+
return _handle.AddrOfPinnedObject();
149+
}
150+
}
142151

143152
public void Dispose()
144153
{

0 commit comments

Comments
 (0)