Skip to content

Commit

Permalink
Fix pointers >= 2**31.
Browse files Browse the repository at this point in the history
  • Loading branch information
shoestringresearch committed May 13, 2023
1 parent 57d7ff8 commit 399f1da
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wa-sqlite",
"version": "0.9.0",
"version": "0.9.1",
"type": "module",
"main": "src/sqlite-api.js",
"types": "src/types/index.d.ts",
Expand Down
8 changes: 4 additions & 4 deletions src/libmodule.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ const mod_methods = {
const struct = {};
struct['nConstraint'] = getValue(p + offset[0], 'i32');
struct['aConstraint'] = [];
const constraintPtr = getValue(p + offset[1], 'i32');
const constraintPtr = getValue(p + offset[1], '*');
const constraintSize = mapStructToLayout.get('sqlite3_index_constraint').size;
for (let i = 0; i < struct['nConstraint']; ++i) {
struct['aConstraint'].push(
unpack_sqlite3_index_constraint(constraintPtr + i * constraintSize));
}
struct['nOrderBy'] = getValue(p + offset[2], 'i32');
struct['aOrderBy'] = [];
const orderPtr = getValue(p + offset[3], 'i32');
const orderPtr = getValue(p + offset[3], '*');
const orderSize = mapStructToLayout.get('sqlite3_index_orderby').size;
for (let i = 0; i < struct['nOrderBy']; ++i) {
struct['aOrderBy'].push(
Expand Down Expand Up @@ -117,7 +117,7 @@ const mod_methods = {
function pack_sqlite3_index_info(p, struct) {
const layout = mapStructToLayout.get('sqlite3_index_info');
const offset = layout.offsets;
const usagePtr = getValue(p + offset[4], 'i32');
const usagePtr = getValue(p + offset[4], '*');
const usageSize = mapStructToLayout.get('sqlite3_index_constraint_usage').size;
for (let i = 0; i < struct['nConstraint']; ++i) {
pack_sqlite_index_constraint_usage(
Expand All @@ -129,7 +129,7 @@ const mod_methods = {
const length = lengthBytesUTF8(struct['idxStr']);
const z = ccall('sqlite3_malloc', 'number', ['number'], [length + 1]);
stringToUTF8(struct['idxStr'], z, length + 1);
setValue(p + offset[6], z, 'i32');
setValue(p + offset[6], z, '*');
setValue(p + offset[7], 1, 'i32');
}
setValue(p + offset[8], struct['orderByConsumed'], 'i32');
Expand Down
6 changes: 3 additions & 3 deletions src/sqlite-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ export function Factory(Module) {
zVfs = createUTF8(zVfs);
const result = await f(zFilename, tmpPtr[0], flags, zVfs);

const db = Module.getValue(tmpPtr[0], 'i32');
const db = Module.getValue(tmpPtr[0], '*');
databases.add(db);
Module._sqlite3_free(zVfs);

Expand All @@ -507,10 +507,10 @@ export function Factory(Module) {
const result = await f(db, sql, -1, tmpPtr[0], tmpPtr[1]);
check(fname, result, db);

const stmt = Module.getValue(tmpPtr[0], 'i32');
const stmt = Module.getValue(tmpPtr[0], '*');
if (stmt) {
mapStmtToDB.set(stmt, db);
return { stmt, sql: Module.getValue(tmpPtr[1], 'i32') };
return { stmt, sql: Module.getValue(tmpPtr[1], '*') };
}
return null;
};
Expand Down

0 comments on commit 399f1da

Please sign in to comment.