Skip to content

Commit

Permalink
fix(getColumn): handle the case in which sqlite3_column_blob can retu…
Browse files Browse the repository at this point in the history
…rn nullptr if the blob is of length zero

fix #122
  • Loading branch information
DjDeveloperr authored Mar 16, 2024
1 parent fa99ea8 commit d4c4443
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/statement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,14 @@ function getColumn(handle: Deno.PointerValue, i: number, int64: boolean): any {

case SQLITE_BLOB: {
const ptr = sqlite3_column_blob(handle, i);

if (ptr === null) {
return new Uint8Array();
}

const bytes = sqlite3_column_bytes(handle, i);
return new Uint8Array(
Deno.UnsafePointerView.getArrayBuffer(ptr!, bytes).slice(0),
Deno.UnsafePointerView.getArrayBuffer(ptr, bytes).slice(0),
);
}

Expand Down

0 comments on commit d4c4443

Please sign in to comment.