Skip to content

Commit 0f13e65

Browse files
committed
refactor: improve limit validation by checking indices instead of bounds
1 parent c0c009a commit 0f13e65

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/node_sqlite.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,16 @@ static_assert(kLimitMapping.size() ==
4444
static_cast<size_t>(SQLITE_LIMIT_TRIGGER_DEPTH + 1),
4545
"kLimitMapping must cover all SQLite limits");
4646

47-
constexpr bool CheckLimitBounds() {
48-
for (const auto& info : kLimitMapping) {
49-
if (info.sqlite_limit_id < 0 ||
50-
info.sqlite_limit_id > SQLITE_LIMIT_TRIGGER_DEPTH) {
47+
constexpr bool CheckLimitIndices() {
48+
for (size_t i = 0; i < kLimitMapping.size(); ++i) {
49+
if (kLimitMapping[i].sqlite_limit_id != static_cast<int>(i)) {
5150
return false;
5251
}
5352
}
5453
return true;
5554
}
56-
static_assert(
57-
CheckLimitBounds(),
58-
"All kLimitMapping entries must be <= SQLITE_LIMIT_TRIGGER_DEPTH");
55+
static_assert(CheckLimitIndices(),
56+
"Each kLimitMapping entry's sqlite_limit_id must match its index");
5957

6058
class DatabaseOpenConfiguration {
6159
public:

0 commit comments

Comments
 (0)