Skip to content

Commit

Permalink
Now get_cell and is_cell_null in Sqlite3QueryResult will do a bounds …
Browse files Browse the repository at this point in the history
…check via error macros.

This means indexing errors will not result in a crash due to vectors
using CRASH_BAD_INDEX error macros.
  • Loading branch information
Relintai committed Dec 11, 2024
1 parent e210e8d commit 9da9dbc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions modules/database_sqlite/sqlite3_query_result.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "sqlite3_query_result.h"

#include "./sqlite/sqlite3.h"
#include "core/error/error_macros.h"
#include "core/string/print_string.h"
#include "core/string/ustring.h"
#include <cstdio>
Expand All @@ -16,10 +17,16 @@ int Sqlite3QueryResult::get_stored_row_count() {
}

String Sqlite3QueryResult::get_cell(const int index) {
ERR_FAIL_INDEX_V(current_row, rows.size(), String());
ERR_FAIL_INDEX_V(index, rows[current_row]->cells.size(), String());

return rows[current_row]->cells[index].data;
}

bool Sqlite3QueryResult::is_cell_null(const int index) {
ERR_FAIL_INDEX_V(current_row, rows.size(), true);
ERR_FAIL_INDEX_V(index, rows[current_row]->cells.size(), true);

return rows[current_row]->cells[index].null;
}

Expand Down

0 comments on commit 9da9dbc

Please sign in to comment.