Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions cpp/bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,8 @@
// buffer with explicit length so embedded zero bytes in the key are
// preserved, and it never enters trace/log surfaces — defense in
// depth, not an exploit class on its own.
int key_status = sqlite3_key_v2(
db, "main", encryption_key.data(),
static_cast<int>(encryption_key.size()));
int key_status = sqlite3_key_v2(db, "main", encryption_key.data(),
static_cast<int>(encryption_key.size()));
if (key_status != SQLITE_OK) {
const char *message = sqlite3_errmsg(db);
throw std::runtime_error(
Expand Down Expand Up @@ -328,7 +327,7 @@
if (isFailed) {
throw std::runtime_error(
"[op-sqlite] SQLite code: " + std::to_string(result) +
" execution error: " + std::string(errorMessage));

Check warning on line 330 in cpp/bridge.cpp

View workflow job for this annotation

GitHub Actions / ios-sqlcipher

variable 'errorMessage' may be uninitialized when used here [-Wconditional-uninitialized]

Check warning on line 330 in cpp/bridge.cpp

View workflow job for this annotation

GitHub Actions / ios-embedded

variable 'errorMessage' may be uninitialized when used here [-Wconditional-uninitialized]

Check warning on line 330 in cpp/bridge.cpp

View workflow job for this annotation

GitHub Actions / ios-embedded

variable 'errorMessage' may be uninitialized when used here [-Wconditional-uninitialized]

Check warning on line 330 in cpp/bridge.cpp

View workflow job for this annotation

GitHub Actions / ios

variable 'errorMessage' may be uninitialized when used here [-Wconditional-uninitialized]
}

int changedRowCount = sqlite3_changes(db);
Expand Down Expand Up @@ -642,7 +641,7 @@
if (isFailed) {
throw std::runtime_error(
"[op-sqlite] SQLite error code: " + std::to_string(result) +
", description: " + std::string(errorMessage));

Check warning on line 644 in cpp/bridge.cpp

View workflow job for this annotation

GitHub Actions / ios-sqlcipher

variable 'errorMessage' may be uninitialized when used here [-Wconditional-uninitialized]

Check warning on line 644 in cpp/bridge.cpp

View workflow job for this annotation

GitHub Actions / ios-embedded

variable 'errorMessage' may be uninitialized when used here [-Wconditional-uninitialized]

Check warning on line 644 in cpp/bridge.cpp

View workflow job for this annotation

GitHub Actions / ios-embedded

variable 'errorMessage' may be uninitialized when used here [-Wconditional-uninitialized]

Check warning on line 644 in cpp/bridge.cpp

View workflow job for this annotation

GitHub Actions / ios

variable 'errorMessage' may be uninitialized when used here [-Wconditional-uninitialized]
}

int changedRowCount = sqlite3_changes(db);
Expand All @@ -652,8 +651,7 @@
.insertId = static_cast<double>(latestInsertRowId)};
}

/// Executes returning data in raw arrays, a small performance optimization
/// for certain use cases
/// Executes returning data in raw arrays
BridgeResult
opsqlite_execute_raw(sqlite3 *db, std::string const &query,
const std::vector<JSVariant> *params,
Expand All @@ -666,6 +664,7 @@
bool isFailed = false;

int step = SQLITE_OK;
std::vector<std::string> column_names;

do {
const char *queryStr =
Expand Down Expand Up @@ -696,6 +695,13 @@

int column_count = sqlite3_column_count(statement);

column_names.clear();
column_names.reserve(column_count);
for (int column_index = 0; column_index < column_count; column_index++) {
column_name = sqlite3_column_name(statement, column_index);
column_names.emplace_back(column_name);
}

while (isConsuming) {
step = sqlite3_step(statement);

Expand Down Expand Up @@ -774,14 +780,15 @@
if (isFailed) {
throw std::runtime_error(
"[op-sqlite] SQLite error code: " + std::to_string(step) +
", description: " + std::string(errorMessage));

Check warning on line 783 in cpp/bridge.cpp

View workflow job for this annotation

GitHub Actions / ios-sqlcipher

variable 'errorMessage' may be uninitialized when used here [-Wconditional-uninitialized]

Check warning on line 783 in cpp/bridge.cpp

View workflow job for this annotation

GitHub Actions / ios-embedded

variable 'errorMessage' may be uninitialized when used here [-Wconditional-uninitialized]

Check warning on line 783 in cpp/bridge.cpp

View workflow job for this annotation

GitHub Actions / ios-embedded

variable 'errorMessage' may be uninitialized when used here [-Wconditional-uninitialized]

Check warning on line 783 in cpp/bridge.cpp

View workflow job for this annotation

GitHub Actions / ios

variable 'errorMessage' may be uninitialized when used here [-Wconditional-uninitialized]
}

int changedRowCount = sqlite3_changes(db);
long long latestInsertRowId = sqlite3_last_insert_rowid(db);

return {.affectedRows = changedRowCount,
.insertId = static_cast<double>(latestInsertRowId)};
.insertId = static_cast<double>(latestInsertRowId),
.column_names = std::move(column_names)};
}

std::string operation_to_string(int operation_type) {
Expand Down
Loading
Loading