Skip to content

fix(cpp): out-of-bounds read in delete() when a location is passed#404

Closed
pbbadenhorst wants to merge 1 commit into
OP-Engineering:mainfrom
pbbadenhorst:fix/delete-args-index-oob
Closed

fix(cpp): out-of-bounds read in delete() when a location is passed#404
pbbadenhorst wants to merge 1 commit into
OP-Engineering:mainfrom
pbbadenhorst:fix/delete-args-index-oob

Conversation

@pbbadenhorst
Copy link
Copy Markdown
Contributor

Summary

The delete JSI host function in cpp/DBHostObject.cpp checks count == 1 for the optional location argument, but then reads args[1] instead of args[0]. Calling db.delete(location) therefore reads past the end of the JSI argument list — undefined behaviour, can crash native code.

Also fixes a stale error string in the same block that referred to [op-sqlite][open] instead of [op-sqlite][delete].

Changes

  • cpp/DBHostObject.cpp: use args[0] for the optional location argument; correct the error message tag.
  • example/src/tests/dbsetup.ts: add two regression tests — one that calls db.delete(location) with a valid string, and one that asserts a non-string argument is rejected by the type guard.

@pbbadenhorst
Copy link
Copy Markdown
Contributor Author

Closing, see #405

@pbbadenhorst pbbadenhorst deleted the fix/delete-args-index-oob branch May 18, 2026 05:19
@OP-Engineering OP-Engineering deleted a comment from oscar-opacity May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant