Skip to content

Commit 842f0aa

Browse files
committed
Return null from GetString or GetBytes if pointer returned is null
1 parent 2d886ed commit 842f0aa

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Runtime/SQLitePreparedStatement.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@ public string GetString(int column)
225225
{
226226
ThrowIfDisposed();
227227
IntPtr ptr = SQLite3.ColumnText16(_preparedStatement, column);
228+
if (ptr == IntPtr.Zero)
229+
{
230+
return null;
231+
}
228232
int sizeInBytes = SQLite3.ColumnBytes16(_preparedStatement, column);
229233
return Marshal.PtrToStringUni(ptr, sizeInBytes / sizeof(char));
230234
}
@@ -233,6 +237,10 @@ public byte[] GetBytes(int column)
233237
{
234238
ThrowIfDisposed();
235239
IntPtr blob = SQLite3.ColumnBlob(_preparedStatement, column);
240+
if (blob == IntPtr.Zero)
241+
{
242+
return null;
243+
}
236244
int sizeInBytes = SQLite3.ColumnBytes(_preparedStatement, column);
237245
var value = new byte[sizeInBytes];
238246
Marshal.Copy(blob, value, 0, sizeInBytes);

0 commit comments

Comments
 (0)