Skip to content

Fix crashes when binding or reading blob values #86

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 13, 2025
Merged

Conversation

simolus3
Copy link
Contributor

This fixes two issues:

  1. When binding a JS ArrayBuffer as a blob value, we used to pass the underlying data pointer of the buffer to the shared_ptr constructor. This makes the value take ownership of the underlying contents, which is not correct! The JS engine keeps ownership of data, we should clone instead. Binding the buffer causes a duplicate free when the JS engine eventually collects garbage, crashing the app.
  2. When reading SQLITE_BLOB values, memcpy was called on an uninitialized uint8_t *. Writing into the uninitialized pointer is undefined behavior (crashing the app is a best-case scenario here).

@simolus3 simolus3 requested a review from stevensJourney May 13, 2025 14:21
@simolus3 simolus3 merged commit e3f5c79 into main May 13, 2025
3 checks passed
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.

2 participants